To get file size in bytes using NSFileManager do the following:
1 2 |
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:_filePath error:nil]; _size = [attrs fileSize]; |
This solution worked for me under iOS 6.1:
Close the simulator if it is running xcode project.
Run simulator from the dock by clicking on it.
Drag & drop the image into simulator.
Tap and hold the image (opened in safari) and select the save option.
You are done.
Taken from here.
To change edge insets in UITextField, create a new subclass and override these methods:
1 2 3 4 5 6 7 8 9 |
// placeholder position - (CGRect)textRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 0, 10); } // text position - (CGRect)editingRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 0, 10); } |
Here 0 is dx, 10 is dy.
Found this nice solution here
I loadView create a UITextField ivar.
1 2 3 4 5 6 7 8 9 10 11 |
- (void)loadView { [super loadView]; _userNameTextField = [[UITextField alloc] initWithFrame:CGRectMake(30, 10, 280, 30)]; _userNameTextField.placeholder = @"Введите имя пользователя"; [_userNameTextField setClearButtonMode:UITextFieldViewModeWhileEditing]; _userNameTextField.returnKeyType = UIReturnKeyGo; _userNameTextField.delegate = self; _userNameTextField.tag = 1; ... |
In ViewDidAppear make it first responder:
1 2 3 4 5 6 |
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [_userNameTextField becomeFirstResponder]; } |
In cellForRow add it as a subview:
1 2 3 4 5 6 |
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] init]; if (indexPath.section == 0) { if (indexPath.row == 0) { [cell addSubview:_userNameTextField]; |
Взять любое кастмное View на данном экране. Добавить в его коде:
1 2 3 4 |
- (BOOL)canBecomeFirstResponder { return YES; // Для отлавления Shake события } |
При загрузке данного View Controller и инциализации данного View делать следующее:
1 |
[_composeButton becomeFirstResponder]; // Для отлавления Shake события |
Добавить следующий метод в данном View Controller.
1 2 3 4 5 6 7 8 9 10 |
// Для отлавления Shake события - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { // Обработка события встряхивания if ( event.subtype == UIEventSubtypeMotionShake ) { NCLog(@"Shaked"); if ( UD_BOOL(UDKeyNewMessageOnShake) ) [self showComposeEmailViewControllerInMode:kComposeModeNew WithMCMessageFromIndexPath:nil]; } } |
Все!
This is very popular question in StackOverflow.
However, the best answer for XCode 4.6 is this:
“In your project Build Settings, under Other Warning Flags (WARNING_CFLAGS), add
-Wno-arc-performSelector-leaks
Now just make sure that the selector you are calling does not cause your object to be retained or copied.”
“Note you can add the same flag for specific files rather than the entire project. If you look under Build Phases->Compile Sources, you can set per file Compiler Flags (just like you want to do for excluding files from ARC). In my project just one file should use selectors this way, so I just excluded it and left the others.”
Code snippet:
1 |
-Wno-arc-performSelector-leaks |