0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//cell.textLabel.font = [UIFont fontWithName:@"Arial" size:10.0f];
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row)
{
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height < 568)
{
CGRect newFrame = tableView.frame;
newFrame.size.height=iOSDeviceScreenSize.height;
tableView.frame=newFrame;
}
}
}
Autolayout своими руками
bdevnameless ,
30.03.2016 (Updated 29.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
+ (UIView *) createTextField:(NSString *)placeholder {
UIView * view = [UIView new];
view.frame = CGRectMake(0, 0, 100, 50);
view.autoresizesSubviews = YES;
view.backgroundColor = [UIColor whiteColor];
view.layer.borderWidth = 0.5;
view.layer.borderColor = COLOR(204, 204, 204).CGColor;
view.layer.cornerRadius = 5;
view.exclusiveTouch = YES;
UITextField * testField = [UITextField new];
testField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
testField.textColor = [UIColor blackColor];
testField.borderStyle = UITextBorderStyleNone;
testField.autocorrectionType = UITextAutocorrectionTypeNo;
[view addSubview:testField];
return view;
}
Потом у нас есть какойто контроллер
- (void)viewDidLoad {
[super viewDidLoad];
textField = [[MyClass createTextField:@"CITY, STATE OR ZIP"] subviews][0];
textField.returnKeyType = UIReturnKeySearch;
textField.delegate = (id<UITextFieldDelegate>)self;
[self.view addSubview:textField.superview];
}
На iOS 8.4 на устройстве текстфилд не будет отображаться
Нужно делать так:
UIView * v = [MyClass createTextField:@"CITY, STATE OR ZIP"];
textField = [v subviews][0];
[self.view addSubview:textField.superview];
COCOK-MAMOHTA ,
05.03.2016 (Updated 29.03.2018 )
0
1 2
- (void)setupBottomObjects:(NSArray *)bottomObjects
topObjects:(NSArray *)topObjects;
besprincypniycentner ,
01.03.2016 (Updated 29.03.2018 )
0
1
@property (weak, weak, weak, weak, weak) IBOutlet UIView *veryWeakView;
besprincypniycentner ,
13.02.2016 (Updated 29.03.2018 )
0
1 2 3 4
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (![_searchBarWhite.text isEqualToString:@""] || ![_searchBarBlue.text isEqualToString:@""]) {
if (![[[LanguageList enumToString:[LanguageList indexOfItem:[[[[LanguageSelectDemon summon]getObjectAtIndex:indexPath.row]lastPathComponent]stringByDeletingPathExtension]]] lowercaseString] containsString:[[_searchBarWhite.text isEqualToString:@""]?_searchBarBlue.text:_searchBarWhite.text lowercaseString]]){
return 0;}}}
начальство заставило писать функции макс на 4 строчки, и которые делают "одну вещи", вот итоги...
4oby ,
06.02.2016 (Updated 29.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
NSError* utilitiesCheckEmail(NSString* string)
{
NSInteger email_symbol_count=0;
NSInteger pos_email_symbol=0;
NSInteger pos_point=0;
NSInteger count=string.length;
if(count!=0)
{
unichar buffer[count];
[string getCharacters:buffer];
for(NSInteger i=0;i<count;i++)
{
unichar ch=buffer[i];
if( !( (ch>='a') && (ch<='z') ) && !( (ch>='A') && (ch<='Z') ) && !( (ch>='0') && (ch<='9') ) && (ch!='_') && (ch!='-') )
{
switch (ch)
{
case '@':
{
email_symbol_count++;
pos_email_symbol=i;
break;
}
case '.':
{
pos_point=i;
break;
}
default:
return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
}
}
}
if( (email_symbol_count==1) && (pos_point!=0) && (pos_point>pos_email_symbol) && ((pos_point+1)<count) )
return NULL;
}
return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
}
Валидируем email
def ,
25.01.2016 (Updated 29.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- (void) findFileTimeout: (NSTimer *) t {
[detectFileTimerTimeout invalidate];
detectFileTimerTimeout = nil;
[detectFileTimer invalidate];
detectFileTimer = nil;
[WriteToLog WriteToLog:@"Timeout reached!"];
[WriteToLog WriteToLog:@"Closing..."];
exit(0);
[NSApp terminate:nil];
[[NSApplication sharedApplication] terminate:nil];
}
Выход по таймауту
EMax ,
14.01.2016 (Updated 29.03.2018 )
0
1 2 3 4 5 6 7 8 9 10
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index
{
switch (index) {
case 0: STLog(@"left button 0 was pressed"); break;
case 1: STLog(@"left button 1 was pressed"); break;
case 2: STLog(@"left button 2 was pressed"); break;
case 3: STLog(@"left btton 3 was pressed"); break;
default: break;
}
}
логируем кнопочки
Disconnecter1987 ,
09.12.2015 (Updated 29.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
- (void)jumpToClass:(int)cIndex pageIndex:(int)pIndex {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
//trick to store pIndex and cIndex
int calc = cIndex*100;
calc = calc + pIndex;
indicator.tag = calc; //trick to store pIndex
[self.view addSubview:indicator];
[indicator bringSubviewToFront:self.view];
[indicator startAnimating];
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(asyncJumpToClass:)
userInfo:indicator
repeats:NO];
}
- (void)asyncJumpToClass:(NSTimer*)theTimer {
UIActivityIndicatorView *ind = (UIActivityIndicatorView *)[theTimer userInfo];
int pIndex = ind.tag%100;
int cIndex = ind.tag/100;
// еще 30 строк кода
}
Передача параметров
Headless ,
17.11.2015 (Updated 29.03.2018 )
0
1 2 3 4
- (void)drawTextInRect:(CGRect)rect {
CGRect bounds = CGRectInset(rect, 0.f, 0.f);
[super drawTextInRect:bounds];
}
besprincypniycentner ,
18.10.2015 (Updated 29.03.2018 )