This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make sure Product->Scheme->Edit Scheme->Run is using "Debug" mode | |
(lldb) p NSPointFromString(@"{10.0, 20.0}"); | |
error: 'NSPointFromString' has unknown return type; cast the call to its declared return type | |
error: 1 errors parsing expression | |
(lldb) p (NSPoint)NSPointFromString(@"{10.0, 20.0}”); | |
(NSPoint) $0 = (x = 10, y = 20) | |
(lldb) e @import UIKit | |
(lldb) po self.view.bounds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To be able to import non-native framework files in Xctest, | |
go to test target configuration -> build settings -> frame work search path, | |
add $(PROJECT_DIR) entry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//with semaphore | |
self.sem = disptach_semaphore_create(0); | |
[someAsyncTask start]; //someAsyncTask needs to call dispatch_semaphore_signal(self.sem) after the its work is done. | |
disptach_semaphore_wait(self.sem, DISPATCH_TIME_FOREVER); | |
NSLog(@"task is done!"); | |
//with NSRunloop | |
self.taskIsDone = NO; | |
[someAsyncTask start]; //someAsyncTask needs to set self.taskIsDone = YES after the work is done. | |
while (!self.taskIsDone) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The main queue must be associated with the main thread. | |
//The main thread is not exclusively associated with the main queue. | |
//For example, when disptach_sync is used to dispatch a task from queue A to queue B, | |
//queue B will use the same thread queue A is using to execute the task. | |
//So, if a task is dispatched to a non-main queue from the main queue with dispatch_sync, | |
//the non-main queue will use the main thread to execute the task. | |
//Check if a task is running on the main thread, | |
[NSThread isMianThread]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The cause of this problem is when the contentInset is set, contentOffset is also set to a value according to the new value of contentInset. | |
So restore contentOffset to its old value after setting contentInset solves the problem. | |
It seems the animation block is not needed in my app with iOS 9.0. | |
- (void)setLoadingScrollViewInsets:(UIScrollView *)scrollView | |
{ | |
UIEdgeInsets loadingInset = scrollView.contentInset; | |
loadingInset.top += self.view.frame.size.height; | |
CGPoint contentOffset = scrollView.contentOffset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//need double animation blocks | |
if (self.tableView.contentInset.top == 0) | |
{ | |
UIEdgeInsets tableViewInset = self.tableView.contentInset; | |
tableViewInset.top = -1.*kTableHeaderHeight; | |
[UIView animateWithDuration: 0 animations: ^(void){} completion:^(BOOL finished) { | |
[UIView animateWithDuration: 0.5 animations:^{ | |
//no need to set contentOffset, setting contentInset will change contentOffset accordingly. | |
self.tableView.contentInset = tableViewInset; | |
}]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scrollView.directionalLockEnabled still allows diagonal scrolling. | |
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView | |
{ | |
self.initialOffeset = scrollView.contentOffset; | |
} | |
-(void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
//lock scroll direction | |
CGFloat xdis = scrollView.contentOffset.x - self.initialOffeset.x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//copied from Ben Dodson's website. | |
class ViewController: UIViewController { | |
@IBOutlet weak var label: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: .UIContentSizeCategoryDidChange, object: nil) | |
updateUI() | |
} |
OlderNewer