005
- 2. 2012/11/20 iOS 語法基礎
使用者介面綜觀
• TabBar Controller
• UIScrollView 應用, 動、 放大、縮小
• 實作結合使用者介面及圖 處理的相片瀏覽程式
- 6. UITabBarControllerDelegate
決定某個頁籤是否可以被選上
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:
(UIViewController *)viewController
頁籤被選中後會觸發的事件
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:
(UIViewController *)viewController
通知代理者頁籤位置即將開始被調整
-(void)tabBarController:(UITabBarController *)tabBarController
willBeginCustomizingViewControllers:(NSArray *)viewControllers
通知代理者頁籤位置即將結束調整
-(void)tabBarController:(UITabBarController *)tabBarController
willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
通知代理者頁籤位置已調整完畢
-(void)tabBarController:(UITabBarController *)tabBarController
didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
- 10. 認識 UIScrollView 的 property 與 method
frame
contentSize
contentOffset
contentInset
minimumZoomScale
maximumZoomScale
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:
(float)scale
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
- 11. 在一般的 UIView 加入 subview
subview.frame = ...;
[view addSubview:subview];
- 12. 在一般的 UIView 加入 subview
subview.frame = ...;
[view addSubview:subview];
- 13. 在 UIScrollView 加入 subview
scrollView.contentSize = CGSizeMake(3000, 2000);
subview1.frame = CGRectMake(2700, 100, 120, 180);
[view addSubview:subview];
- 14. 在 UIScrollView 加入 subview
scrollView.contentSize = CGSizeMake(3000, 2000);
subview2.frame = CGRectMake(50, 100, 2500, 1600);
[view addSubview:subview];
- 17. 在 UIScrollView 加入 subview
subview2.frame = CGRectMake(0, 0, 2500, 1600);
scrollView.contentSize = CGSizeMake(2500, 1600);
- 20. 在 UIScrollView 加入 subview
CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:subview];
- 22. 實作練習
ScrollViews
練習
UIPageControl 分頁
UITapGestureRecognizer 手勢
- 23. UIImage
• 直接載入在 App 內的圖片
UIImage *image = [UIImage imageNamed:@"DSC03027.jpg"];
• 網路載入
NSURL *url = [NSURL URLWithString:@”http://xxx.jpg”];
NSData *data = [NSData dataWithContentsOfURL:url];
image = [[UIImageView alloc] initWithImage: [UIImage imageWithData: data]];
• 模擬器路徑
/Users/username/Library/Application Support/iPhone Simulator
• 存到相簿
UIImageWriteToSavedPhotosAlbum(image, self,
@selector(image:didFinishSavingWithError:contextInfo:), nil);
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:
(void *)contextInfo
範例 scroll_enhanced
- 25. UIImagePickerController
• sourceType
UIImagePickerControllerSourceTypePhotoLibrary, //圖庫中的所有資料夾
UIImagePickerControllerSourceTypeCamera, //使用相機拍攝新的照片或影片
UIImagePickerControllerSourceTypeSavedPhotosAlbum //圖庫中的預設資料夾(相機膠
卷)
範例 album, 11.1.4 可檢視相簿圖形(p.11-8)
- 27. 沈志宗 Stronger Shen (Appletrees)
• http://mit.com.tw
http://iphone.to
• stronger@mit.com.tw
shen@iphone.to
strongershen@gmail.com
Hinweis der Redaktion
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n