ios NSdate 與NSString 之間的轉化

NSString-NSDate類型轉換和CustomBar的總結
2012-12-22 13:08:53     我來說兩句       作者:newcnzz
收藏    我要投稿
如何將一個字符串@"2012-12-21"轉換成NSDate模式
新的SDK貌似不再支持 [NSDate initWithString]這個方法
那麼現在應該如何轉換呢,以下代碼
NSString --> NSDate:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *tempDate = [dateFormatter dateFromString:@"2012-12-21"];
NSDate --> NSString:
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *dateAndTime = [dateFormatter stringFromDate: date];
今日關於自定義UITabBarController的CustomBar的類庫,
遇到一系列詭異的動畫效果以及之前沒有注意的問題
首先,CustomBar 繼承了UITabBarController
並且擁有相應的顯示 和 隱藏 等方法
方法展示如下
Objectiv-c代碼 :
// 隱藏tabbar  
- (void) hideCustomTabBar{  
    for(UIView *view in self.view.subviews){  
        if([view isKindOfClass:[UIImageView class]]||[view isKindOfClass:[MKNumberBadgeView class]]||[view isKindOfClass:[UIButton class]]){  
            view.hidden = YES;  
        }  
    }  
    slideBg.hidden=YES;  
}  
Oc代碼:  
- (void) showCustomTabBar{  
    for(UIView *view in self.view.subviews){  
        if([view isKindOfClass:[UIImageView class]]||[view isKindOfClass:[MKNumberBadgeView class]]||[view isKindOfClass:[UIButton class]]){  
//            [UIView beginAnimations:nil context:nil];  
//            [UIView animateWithDuration:0.3 animations:nil];  
            view.hidden = NO;  
        }  
    }  
    slideBg.hidden=NO;  
}   
在調用上面的隱藏方法的時候,並不能將tabbar全部隱藏,還留下一條白色不可用區域(tabbar區域)。
如何將其全部隱藏呢?除了調用上述隱藏方法之外,還需要在push的時候調用
hidesBottomBarWhenPushed方法,代碼如下
 
Oc代碼:  
ReadViewController *read = [[ReadViewController alloc] init];  
read.hidesBottomBarWhenPushed = YES;  
[self.navigationController pushViewController:read animated:YES];  
[read release];  
這樣就能將其全部隱藏了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章