{"id":563,"date":"2018-02-23T23:40:04","date_gmt":"2018-02-23T15:40:04","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/ios%e5%b7%a5%e5%85%b7%e6%a0%8f\/"},"modified":"2018-02-23T23:40:04","modified_gmt":"2018-02-23T15:40:04","slug":"ios%e5%b7%a5%e5%85%b7%e6%a0%8f","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=563","title":{"rendered":"iOS\u5de5\u5177\u680f"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h2>\u5de5\u5177\u680f\u7684\u4f7f\u7528<\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u680f\u4fee\u6539\u89c6\u56fe\u5143\u7d20\u3002<\/p>\n<p>\u5982\uff0c\u90ae\u4ef6\u5e94\u7528\u7a0b\u5e8f\u91cc\u7684\u6536\u4ef6\u7bb1\u680f\u4e2d\u6709\u5220\u9664\u3001\u5206\u4eab\u3001\u7b54\u590d\u7b49\u7b49\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"toolbar\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/toolbar.jpg\" width=\"254\" height=\"40\"><\/p>\n<p>\u91cd\u8981\u7684\u5c5e\u6027<\/p>\n<ul>\n<li>barStyle<\/li>\n<li>items<\/li>\n<\/ul>\n<h2>\u6dfb\u52a0\u81ea\u5b9a\u4e49\u65b9\u6cd5\u00a0addToolbar<\/h2>\n<pre>-(void)addToolbar\n{\n    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] \n    initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace\n    target:nil action:nil];\n    UIBarButtonItem *customItem1 = [[UIBarButtonItem alloc]\n    initWithTitle:@\"Tool1\" style:UIBarButtonItemStyleBordered \n    target:self action:@selector(toolBarItem1:)];\n    UIBarButtonItem *customItem2 = [[UIBarButtonItem alloc]\n    initWithTitle:@\"Tool2\" style:UIBarButtonItemStyleDone \n    target:self action:@selector(toolBarItem2:)];\n    NSArray *toolbarItems = [NSArray arrayWithObjects: \n    customItem1,spaceItem, customItem2, nil];\n    UIToolbar *toolbar = [[UIToolbar alloc]initWithFrame:\n    CGRectMake(0, 366+54, 320, 50)];\n    [toolbar setBarStyle:UIBarStyleBlackOpaque];\n    [self.view addSubview:toolbar];\n    [toolbar setItems:toolbarItems];\n}<\/pre>\n<p>\u4e3a\u4e86\u89e3\u6240\u6267\u884c\u7684\u64cd\u4f5c\u6211\u4eec\u5728\u6211\u4eec\u7684ViewController.xib\u4e2d\u6dfb\u52a0UILabel Iboutlet\u5e76\u4e3a\u00a0UILabel\u00a0\u521b\u5efa\u547d\u540d\u4e3a\u6807\u7b7e\u7684IBoutlet\u3002<\/p>\n<p>\u6211\u4eec\u8fd8\u9700\u8981\u6dfb\u52a0\u4e24\u4e2a\u65b9\u6cd5\u6765\u6267\u884c\uff0c\u5982\u4e0b\u6240\u793a\u7684\u5de5\u5177\u680f\u9879\u7684\u64cd\u4f5c:<\/p>\n<pre>-(IBAction)toolBarItem1:(id)sender{\n    [label setText:@\"Tool 1 Selected\"];\n}\n\n-(IBAction)toolBarItem2:(id)sender{\n    [label setText:@\"Tool 2 Selected\"];    \n}<\/pre>\n<p>\u5728ViewController.m\u4e2d\u66f4\u65b0\u00a0viewDidLoad\uff0c\u5982\u4e0b\u6240\u793a:<\/p>\n<pre>- (void)viewDidLoad\n{\n    [super viewDidLoad];\n    \/\/ The method hideStatusbar called after 2 seconds\n    [self addToolbar];    \n    \/\/ Do any additional setup after loading the view, typically from a nib.\n}<\/pre>\n<h2>\u8f93\u51fa<\/h2>\n<p>\u73b0\u5728\u5f53\u6211\u4eec\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u6211\u4eec\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u8f93\u51fa\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"toolbarOutput\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/toolbarOutput.jpg\" width=\"141\" height=\"264\" data-pinit=\"registered\"><\/p>\n<p>\u5355\u51fb\u6211\u4eec\u5f97\u5230\u7684\u00a0tool1\u00a0\u548c\u00a0tool2\u00a0\u680f\u6309\u94ae<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"toolbarActionOutput\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/toolbarActionOutput.jpg\" width=\"311\" height=\"267\" data-pinit=\"registered\"><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">\u5de5\u5177\u680f\u7684\u4f7f\u7528 \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u680f\u4fee\u6539\u89c6\u56fe\u5143\u7d20\u3002 \u5982\uff0c\u90ae\u4ef6\u5e94\u7528\u7a0b\u5e8f\u91cc\u7684\u6536\u4ef6\u7bb1\u680f\u4e2d\u6709\u5220\u9664\u3001\u5206\u4eab&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=563\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,26],"tags":[74,93],"class_list":["post-563","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobile","tag-ios","tag-mobile","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=563"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/563\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}