ios基礎筆記(一)

來源:互聯網
上載者:User

標籤:

1.    設定按鈕文字的尺寸 為 按鈕自己的尺寸     button.size = [button.currentTitle sizeWithFont:button.titleLabel.font];     button.backgroundColor=[UIColor redColor];2.    常用尺寸/** 44 : cell的預設高度、導覽列的可見高度 49 : UITabBar的預設高度 64 : 從視窗頂部到導覽列底部 20 : 狀態列高度 320 : 豎屏情況下的螢幕寬度 480 : 豎屏情況下的3.5 inch 的螢幕高度 568 : 豎屏情況下的4.0 inch 的螢幕高度 */3.    textview改變通知#warning 不要設定自己的代理為自己本身        // 監聽內部文字改變//        self.delegate = self;                /**         監聽控制項的事件:         1.delegate         2.- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;         3.通知         */                // 當使用者通過鍵盤修改了self的文字,self就會自動發出一個UITextViewTextDidChangeNotification通知        // 一旦發出上面的通知,就會調用self的textDidChange方法        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange) name:UITextViewTextDidChangeNotification object:self];4.    copy策略,重寫setter方法,- (void)setPlacehoder:(NSString *)placehoder{#warning 如果是copy策略,setter最好這麼寫    _placehoder = [placehoder copy];        // 設定文字    self.placehoderLabel.text = placehoder;        // 重新計運算元控制項的fame,    [self setNeedsLayout];//重新布局子控制項}4.    UiTabbar  bug修複- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UINavigationController *)viewController{    UIViewController *vc = [viewController.viewControllers firstObject];    if ([vc isKindOfClass:[HMHomeViewController class]]) {        if (self.lastSelectedViewContoller == vc) {            [self.home refresh:YES];        } else {            [self.home refresh:NO];        }    }        self.lastSelectedViewContoller = vc;}    self.lastSelectedViewContoller = vc;    /**     其實在這裡隱藏著一個問題,如果你的4個TabBar都是指向4個NavigationController,那麼沒有問題,運行OK。     但如果你的4個TabBar有任何一個指向的不是NavigationController,那麼程式就會crash。因為非NavigationController不能夠響應 popToRootViewControllerAnimated: 方法。     */        if ([viewController isKindOfClass:[UINavigationController class]]) {        [(UINavigationController *)viewController popToRootViewControllerAnimated:YES];    }

 

ios基礎筆記(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.