在ios7開發中遇到的一些deprecated的問題

來源:互聯網
上載者:User

cell.textLabel.textAlignment = UITextAlignmentCenter;

現在要寫成cell.textLabel.textAlignment =NSTextAlignmentCenter;


UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];

需要寫成

static NSString *TableSampleIdentifier =@"TableSampleIdentifier";

UITableViewCell *cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleValue1reuseIdentifier:TableSampleIdentifier];


[selfpresentModalViewController:calendarViewanimated:YES];

改成 [selfpresentViewController:calendarViewanimated:YEScompletion:^{}];

新介面的差別是提供了一個參數,允許你傳入一個block。這個block的回調方法在VC的viewWillDisappear方法後調用。也就是被隱藏的VC對象被釋放後運行回調。

這樣做的好處:可以方便做多個UI效果之間的銜接和轉換。


在IOS7的PageControl控制項

調用[self.subviewsobjectAtIndex:i]

取出的不是UIImageView而是UIView

所以updateDots方法應該這樣寫:

-(void) updateDots{        for (int i = 0; i < [self.subviews count]; i++) {        UIView* dotView = [self.subviews objectAtIndex:i];                if ([dotView isKindOfClass:[UIImageView class]]) {            UIImageView* dot = (UIImageView*)dotView;            if (i == self.currentPage)                dot.image = _activeImage;            else                dot.image = _inactiveImage;        }else{            if (i == self.currentPage)                [dotView setBackgroundColor:[UIColor colorWithPatternImage:_activeImage]];            else                [dotView setBackgroundColor:[UIColor colorWithPatternImage:_inactiveImage]];        }           }}

[text drawAtPoint:textPt withFont:[UIFontsystemFontOfSize:14.0f]]

在IOS7中應該寫

 #define NLSystemVersionGreaterOrEqualThan(version)  ([[[UIDevice currentDevice] systemVersion] floatValue] >= version)    #define IOS7_OR_LATER   NLSystemVersionGreaterOrEqualThan(7.0)    if (IOS7_OR_LATER) {        UIFont* font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];        font = [font fontWithSize:14.0f];        [text drawAtPoint:textPt withAttributes:@{NSFontAttributeName:font}];    }else {        [text drawAtPoint:textPt withFont:[UIFont systemFontOfSize:14.0f]];    }




聯繫我們

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