IOS開發基礎知識--片段34,ios基礎知識--34

來源:互聯網
上載者:User

IOS開發基礎知識--片段34,ios基礎知識--34

1:第三方外掛程式SKSTableView在IOS7.1.1出現閃退的問題

解決辦法,修改其內部原始碼:

(NSInteger)subRow{id indexpath = [NSIndexPath class];id subRowObj = objc_getAssociatedObject(indexpath, SubRowObjectKey);return [subRowObj integerValue];}(void)setSubRow:(NSInteger)subRow{id subRowObj = [NSNumber numberWithInteger:subRow];id indexpath = [NSIndexPath class];objc_setAssociatedObject(indexpath, SubRowObjectKey, subRowObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);}

 2:UITableViewCell屬性highLighted、selected的區別

自訂一個cell繼承自UITableViewCell,然後重載它的以下兩個方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;

- (void)setSelected:(BOOL)selected animated:(BOOL)animated;

這兩個方法一個是設定cell的高亮狀態,另一個是設定cell的選中狀態。當我們點擊cell的時候,其實是先設定cell的高亮狀態為YES,然後鬆手的時候再將cell的高亮狀態設定為NO,接著才是設定cell的選中狀態為YES,最後才會去調用delegate中的tableview:didSelectRowAtIndexPath:方法。

由此可見:cell的高亮狀態是不能持久的,即tap的時候會變成高亮,鬆手的時候就會自動化佈建為非高亮狀態。而cell的選中狀態則是可以持久的,我們不去觸發它改變狀態,則選中狀態就不會

下面執行個體為結合POP做的動畫效果(當選中時跟鬆開都有一個相應的動畫效果):

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {    [super setSelected:selected animated:animated];}- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{    [super setHighlighted:highlighted animated:animated];    if (self.highlighted) {        POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewScaleXY];        scaleAnimation.duration = 0.1;        scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 1)];        [self.textLabel pop_addAnimation:scaleAnimation forKey:@"scalingUp"];    } else {        POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];        sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];        sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];        sprintAnimation.springBounciness = 20.f;        [self.textLabel pop_addAnimation:sprintAnimation forKey:@"springAnimation"];    }}

 3: UIWebView在IOS9下底部出現黑邊解決方式

UIWebView底部的黑條很難看(在IOS8下不會,在IOS9會出現),特別是在底部還有透明控制項的時候,隱藏的做法其實很簡單,只需要將opaque設為NO,背景色設為clearColor即可

4:UIViewControl中setEdgesForExtendedLayout運用

在iOS 7中,蘋果引入了一個新的屬性,叫做[UIViewController setEdgesForExtendedLayout:],它的預設值為UIRectEdgeAll。當你的容器是navigation controller時,預設的布局將從navigation bar的頂部開始。這就是為什麼所有的UI元素都往上漂移了44pt。

- (void)viewDidLoad{    [super viewDidLoad];    //讓螢幕從導覽列下開始算(0,0)    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {        self.edgesForExtendedLayout = UIRectEdgeNone;    }}

 

相關文章

聯繫我們

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