我在一个viewcontroller中有tableview.我有一节.我想在页脚中添加按钮.我写了这段代码,但页脚视图没有显示.
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *footerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
UIButton *addcharity=[UIButton buttonWithType:UIButtonTypeCustom];
[addcharity setTitle:@"Add to other" forState:UIControlStateNormal];
[addcharity addTarget:self action:@selector(addCharity:) forControlEvents:UIControlEventTouchUpInside];
addcharity.frame=CGRectMake(0, 0, 40, 30);
[footerView addSubview:addcharity];
return footerView;
}
Run Code Online (Sandbox Code Playgroud)
我还在其委托方法中设置了页脚100的高度.
截图:最初我有3个数据.但是当我搜索特定数据并且结果将在tableview中显示时,我有一个数据,所以那时页脚位置发生了变化.我想在最初的地方修剪页脚.


编辑:
作为替代解决方案,可以通过在末尾添加额外的单元来添加按钮.
我有一张图片.我想把它旋转成表面上的硬币旋转.我试过旋转变换,但它没有像那样旋转.如何实现这样的动画?

码:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setUserInteractionEnabled:YES];
lbl_facebook.font=[UIFont fontWithName:GZFont size:12.0f];
txtPassword.font=[UIFont fontWithName:GZFont size:15.0f];
txtUsername.font=[UIFont fontWithName:GZFont size:15.0f];
CATransition* transition = [CATransition animation];
transition.startProgress = 0;
transition.endProgress = 1.0;
transition.type = @"flip";
transition.subtype = @"fromRight";
transition.duration = 0.3;
transition.repeatCount = 2;
[_Image.layer addAnimation:transition forKey:@"transition"];
}
Run Code Online (Sandbox Code Playgroud)
ND:
#import "LoginViewController.h"
#import "RegistrationViewController.h"
#import "ForgetPasswordViewController.h"
#import "ForgetPasswordController.h"
#import "SearchServiceProviderViewController.h"
#import <QuartzCore/QuartzCore.h>
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置表的动态高度.但是当我记录表格的高度时,它显示我动态高度但没有设置为实际表格.
这是我的代码:
CGRect table_frame;
table_frame=table_sender.frame;
NSLog(@"table fram: %f",table_frame.size.height); //got table height 444
float height = [senderHistoryDataArray count] * 40 +40 ; // 4*25.00
NSLog(@"height of table: %f",height); //got this height 200
if(height>=444){
table_frame.size.height=444;
}
else{
table_frame.size.height=height;
NSLog(@"height set"); //also displying this line in log
}
table_sender.frame=table_frame;
[table_sender reloadData];
Run Code Online (Sandbox Code Playgroud)
出局:

当我取消选中自动布局时,它会起作用,但它只显示比以前更多的部分.

我想在我的应用程序中使用AFNetworking类来与服务器通信.
我是这个图书馆的新手.这是我的代码:
NSDictionary *user=[[NSDictionary alloc]initWithObjectsAndKeys:@"hiteshp",@"userName",@"12345^",@"password", nil];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFHTTPRequestSerializer *requestSerializer = [AFHTTPRequestSerializer serializer];
[requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
manager.requestSerializer=requestSerializer; //[AFJSONRequestSerializer serializer];
[manager POST:@"myURL" parameters:user success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@ %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Run Code Online (Sandbox Code Playgroud)
我想为此请求添加标头.我试过但它不起作用.如果我写了注释行,那么请求已完成,但我还想再添加一个字段"Authorization"来重新设置.Andhow打印请求标题?
我想在iOS7中设置工具栏的背景颜色:我用这个设置颜色:
toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,40)];
[toolBar setBarStyle:UIBarStyleBlack];
toolBar.items = [[NSArray alloc] initWithObjects:barButtonDone,flexible,barButtonOther,nil];
toolBar.tintColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"dropdownbar"]];
Run Code Online (Sandbox Code Playgroud)
但是背景图像没有显示.

我想知道这是做什么的:
NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]];
self.navigationController.navigationBar.translucent = NO;
} else {
self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]];
}
Run Code Online (Sandbox Code Playgroud)
Nd如何更改默认导航栏的后退按钮颜色:

我从用户那里获取信用卡号作为输入.我想允许16个数字,并希望在每个4个数字后格式化空格.为此,我做了以下.
-(void)cardNumberValidation:(id)sender{
UITextField *temp=sender;
if ([temp.text length]>19) {
txtCard.text= [temp.text substringToIndex:[temp.text length] - 1];
}
if ([temp.text length]==4) {
txtCard.text=[NSString stringWithFormat:@"%@ ",temp.text];
}
if ([temp.text length]==9) {
txtCard.text=[NSString stringWithFormat:@"%@ ",temp.text];
}
if ([temp.text length]==14) {
NSString *lastChar = [txtCard.text substringFromIndex:[txtCard.text length] - 1];
txtCard.text=[NSString stringWithFormat:@"%@ ",temp.text];
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在当用户输入所有内容后删除字符然后如果它将达到15个字符,然后用户将删除另外一个字符,那么此代码将在其后添加空格,并且不允许进一步删除它.
任何人都可以给我这个或更好的方法来做这个建议.
我通过放大缩小效果显示弹出视图.当我的应用程序将在登录后从safari返回我正在显示该视图.这在模拟器中工作正常.但它不适用于设备.我在ipad检查那件事.这是我的代码:
[MyAppDelegate openSessionWithAllowLoginUI:YES completionBlock:^(BOOL result) {
NSLog(@"Connecte via Joint Page Thank you");
if (result) {
NSLog(@"%@ %d ", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation],[[[NSUserDefaults standardUserDefaults] valueForKey:@"isSender"]boolValue]);
if([[[NSUserDefaults standardUserDefaults] valueForKey:@"isSender"]boolValue]==0 && [[[NSUserDefaults standardUserDefaults] valueForKey:@"isServiceProvider"] boolValue]==0){
lbl_register.font=[UIFont fontWithName:GZFont size:16];
lbl_serviceProvider.font=[UIFont fontWithName:GZFont size:14];
lbl_customer.font=[UIFont fontWithName:GZFont size:14];
SelectionView.center=self.view.center;
SelectionView.layer.borderColor=[[UIColor blackColor] CGColor];
SelectionView.layer.borderWidth=1.0;
SelectionView.layer.cornerRadius=5;
SelectionView.layer.masksToBounds=YES;
[UIView animateWithDuration:0.4 animations:^{
SelectionView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
NSLog(@"popped");
SelectionView.center=self.view.center;
[UIView animateWithDuration:0.4 animations:^{
SelectionView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.95,0.95);
} completion:^(BOOL finished) {
// self.view.userInteractionEnabled=NO;
}];
}];
[self.view addSubview:SelectionView];
Run Code Online (Sandbox Code Playgroud) ios ×7
iphone ×5
ios7 ×4
uitableview ×2
animation ×1
cocoa-touch ×1
objective-c ×1
validation ×1