IOS開發基礎知識--片段2

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   for   strong   

六:獲得另一個控制項器,並實現跳轉

UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];  UIViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"registerViewController"];        registerViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;    [self presentViewController:registerViewController animated:YES completion:^{        NSLog(@"Present Modal View");    }];

 

其中registerViewController是第二個視圖中標識檢查器Storyboard ID的值

 

七:判斷IOS版本

判斷IOS是不是7.0以後的

if([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) {

}

 

八:Button不同狀態下背景圖片

 [_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-n.png"] forState:UIControlStateNormal];

 [_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-s.png"] forState:UIControlStateHighlighted];

 

九:判斷裝置是3.5寸還是4寸

if ([[UIScreen mainScreen] currentMode].size.height == 480||[[UIScreenmainScreen] currentMode].size.height == 960)

{    

//這是3.5寸的iPhone裝置

}

else

{     //這是4寸的iPhone裝置 }

 

十:viewDidLoad中調用

無論你是通過xib檔案還是重寫loadView方法建立UIViewController的view,在view建立完畢後,最終都會調用viewDidLoad方法,一般我們會在這裡做介面上的初始化操作,比如往view中添加一些子視圖、從資料庫或者網路載入模型資料裝配到子視圖中

- (void)viewDidLoad {     [super viewDidLoad];          // 添加一個按鈕     UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];     [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];     [self.view addSubview:button]; }

 

十一:樹形結構導航問題(UINavigationController)

1:如何修改第二頁的返回back文字

應該在第一頁的viewDidLoad裡面進行修改(假設從A介面push到B介面,希望改變B介面的返回按鈕標題,則在A介面中加入代碼),代碼如下:

-(void)viewDidLoad{UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] init] autorelease]; backItem.title = @"返回"; self.navigationItem.backBarButtonItem = backItem;}

 

2:如何增加一個控制項在標題

在本頁的viewDidLoad裡面進行增加;代碼如下:

-(void)viewDidLoad{UIBarButtonItem* Done=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(DownShow)];self.navigationItem.rightBarButtonItem=Done;}-(void)DownShow{}

 

其中按鍵類型如下(帶有不同的表徵圖):

    UIBarButtonSystemItemDone,    UIBarButtonSystemItemCancel,    UIBarButtonSystemItemEdit,      UIBarButtonSystemItemSave,      UIBarButtonSystemItemAdd,    UIBarButtonSystemItemFlexibleSpace,    UIBarButtonSystemItemFixedSpace,    UIBarButtonSystemItemCompose,    UIBarButtonSystemItemReply,    UIBarButtonSystemItemAction,    UIBarButtonSystemItemOrganize,    UIBarButtonSystemItemBookmarks,    UIBarButtonSystemItemSearch,    UIBarButtonSystemItemRefresh,    UIBarButtonSystemItemStop,    UIBarButtonSystemItemCamera,    UIBarButtonSystemItemTrash,    UIBarButtonSystemItemPlay,    UIBarButtonSystemItemPause,    UIBarButtonSystemItemRewind,    UIBarButtonSystemItemFastForward,    UIBarButtonSystemItemUndo,    UIBarButtonSystemItemRedo,    UIBarButtonSystemItemPageCurl//只能在ToolBar上顯示

 

3:如何修改標題的色彩

self.navigationController.navigationBar.tintColor=[UIColor redColor];

 

4:增加其它UISegment,UISwith控制項

在本頁viewDidLoad中增加如下代碼,

    UISegmentedControl *mySegment;    mySegment = [[UISegmentedControl alloc] initWithFrame:CGRectMake(218.0f, 8.0, 100.0f, 30.0f)];     [mySegment insertSegmentWithTitle:@"分配" atIndex:0 animated:YES];     [mySegment insertSegmentWithTitle:@"處理" atIndex:1 animated:YES];     mySegment.segmentedControlStyle = UISegmentedControlStyleBar;     mySegment.selectedSegmentIndex = 0;     [self.navigationController.navigationBar addSubview:mySegment];

 

IOS開發基礎知識--片段2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.