Translate

2015年7月31日 星期五

Custom URL Scheme

參考[iOS] 客製化 URL Scheme (Custom URL Scheme)

播放影片可以直向橫向

參考[iOS] 在WebView播放Youtube影片旋轉 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]] || [[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"XCDYouTubeVideoPlayerViewController")] || [[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"XCDYouTubeVideoPlayerViewController")]) { return UIInterfaceOrientationMaskAll; } else { if ([[window.rootViewController presentedViewController] isKindOfClass:[UINavigationController class]]) { // look for it inside UINavigationController UINavigationController *nc = (UINavigationController *)[window.rootViewController presentedViewController]; // is at the top? if ([nc.topViewController isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAll; // or it's presented from the top? } else if ([[nc.topViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAll; } } } return UIInterfaceOrientationMaskPortrait; }

MPMoviePlayerController play youtube video

github XCDYouTubeKit

iOS 本地化圖片

ios-succinctly-localization

creating-multi-lingual-apps

CustomPhotoAlbum

CustomPhotoAlbum

XCode6 製作Static Framework

XCode6 製作Static Framework

2015年7月23日 星期四

Xcode 6 projectname-prefix-pch

參考文章
Without the question if it is proper or not, you can add PCH file manually:

1.Add new PCH file to the project: New file > Other > PCH file.

2.At the Target's Build Settings option, set the value of Prefix Header to your PCH file name, with the project name as prefix (i.e. for project named TestProject and PCH file named MyPrefixHeaderFile, add the value TestProject/MyPrefixHeaderFile.pch to the plist).

TIP: You can use things like $(SRCROOT) or $(PROJECT_DIR) to get to the path of where you put the .pch in the project.

3.At the Target's Build Settings option, set the value of Precompile Prefix Header to YES.

How to print out the method name and line number and conditionally disable NSLog?

參考文章
#ifdef DEBUG # define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #else # define DLog(...) #endif #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #ifdef DEBUG # define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; } #else # define ULog(...) #endif

2015年7月17日 星期五

得到UIView中某个非子视图在UIView中的位置

轉帖文章
因為很少用到但是又記不起來特地來記錄一下
使用 convertRect: fromView: 或者 convertRect: toView: 例如一个视图控制器的view中有一个UITableView,UITableView的某个cell中有个UITextField,想要得到UITextField在view中的位置,就要靠上面的两个方法了。 用 CGRect rect = [self.view convertRect:textField.frame fromView:textField.superview]; 或者 CGRect rect = [textField.superview convertRect:textField.frame toView:self.view]; 进行转换都可以。

2015年7月16日 星期四

Auto resizing UIWebView content do not fit the frame

- (void)webViewDidFinishLoad:(UIWebView *)webView { CGSize contentSize = [webView sizeThatFits:CGSizeZero]; CGSize viewSize = webView.frame.size; CGFloat rw = viewSize.width / contentSize.width; webView.scrollView.minimumZoomScale = rw; webView.scrollView.maximumZoomScale = rw; webView.scrollView.zoomScale = rw; }

iOS如何设置app支持文件共享

轉帖Ray
轉帖iOS如何设置app支持文件共享
在应用程序的Info.plist文件中添加UIFileSharingEnabled键,并将键值设置为YES