小编Sin*_*hia的帖子

获取UITableView的高度

我创建了一个UITableview自定义UITableViewCell.The UITableViewCell包含UILabels我已经计算基于细胞height.But我怎么能得到的tableview高度的每个单元的高度呢?因为基础上的tableView的高度我需要计算滚动视图的高度,我创建一个UITableView这样当按钮被点击:

-(IBAction)btnClicked:(id)sender
{
    self.tableView=[[UITableView alloc] initWithFrame:CGRectMake(0,150,327,[arr5 count]*205) style:UITableViewStylePlain];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
    float fscrview = 150 + self.tableView.frame.size.height + 20;
    testscroll.contentSize=CGSizeMake(320, fscrview);
  }
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  NSString *city1 = city.text;
        UIFont *font = [UIFont fontWithName:@"Helvetica" size:14.0];
        CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
        CGSize bounds = [city1 sizeWithFont:font constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
//similarly calculated for all 
   return (CGFloat) cell.bounds.size.height + bounds.height+bounds1.height+bounds2.height+bounds3.height+bounds4.height+bounds5.height;
  }
Run Code Online (Sandbox Code Playgroud)

我可以通过这个获得tableViewCells的高度.如何在此之后计算/设置tableView的整体高度?

以及如何根据tableView的行/高度计算ScrollView的高度?

iphone xcode uitableview

9
推荐指数
1
解决办法
2万
查看次数

ToolBar位于xcode中UIPIckerView的顶部?

我需要toolbar在顶部添加一个带完成按钮UIPickerView.我不想使用,actionSheet因为我希望视图的其余部分处于活动状态.我已经去了以下代码:

- (BOOL)textFieldDidBeginEditing:(UITextField *)textField {
  [txtstate resignFirstResponder];
  pickerView = [[UIPickerView alloc]init] ;
  pickerView.frame=CGRectMake(10, 75, 180,20);
  pickerView.delegate = self;
  pickerView.showsSelectionIndicator = YES;

  UIToolbar* toolbar = [[UIToolbar alloc] init];
  toolbar.frame=CGRectMake(0,75,180,10);
  toolbar.barStyle = UIBarStyleBlackTranslucent;
  UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];


  UIBarButtonItem* doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
                                                                       style:UIBarButtonItemStyleDone target:self
                                                                      action:@selector(doneClicked:)];


   [toolbar setItems:[NSArray arrayWithObjects:flexibleSpaceLeft, doneButton, nil]];

   textField.inputAccessoryView = toolbar;
   [pickerView addSubview:toolbar];
   [self.view addSubview:pickerView];
}
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码我的工具栏被添加,但它被隐藏在下面UIPickerView,它将被添加到中间.如何让工具栏出现在前面(在顶部UIPickerView)?

iphone xcode uipickerview uitoolbar

6
推荐指数
2
解决办法
2万
查看次数

识别多个UIL用户点击UITapGestureRecogniser

在我的视图加载中我有两个UILabel,我为两者添加了相同的tapGesture.如果点击一个特定的标签,那么应该执行它的功能.但是我无法这样做?

-(void)viewDidLoad{
  lblEditProfile.userInteractionEnabled = YES;
  UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClicked:)];
    [tapGestureRecognizer setNumberOfTapsRequired:1];
   [lblEditProfile addGestureRecognizer:tapGestureRecognizer];
   [tapGestureRecognizer release];

   lblViewDetails.userInteractionEnabled = YES;
  tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClicked:)];
    [tapGestureRecognizer setNumberOfTapsRequired:1];

    [lblViewDetails addGestureRecognizer:tapGestureRecognizer];
    [tapGestureRecognizer release];
}

-(IBAction)labelClicked:(UITapGestureRecognizer*)tapGestureRecognizer
{

    currentLabel = (UILabel *)tapGestureRecognizer.view;
    NSLog(@"tap %@",tapGestureRecognizer.view);

    if(currentLabel.text==@"Edit Profile")
    {


        UserProfile *userProfile = [[UserProfile alloc] initWithNibName:@"UserProfile" bundle:nil];
        userProfile.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:userProfile animated:YES];
        [userProfile release];



    }
    else
    {

        ViewDetails *viewDetails = [[ViewDetails alloc] initWithNibName:@"UserAppointments" bundle:nil];
        viewDetails.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController: viewDetails animated:YES];
        [viewDetails release];


    } …
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitapgesturerecognizer

3
推荐指数
1
解决办法
1813
查看次数

在xcode中将图像添加到导航栏?

我在xib中添加了导航栏和导航项.现在我需要在导航栏的左侧添加图像,但它没有被添加.这是我正在处理的代码:

- (void)viewDidLoad
{
UIImage *image = [UIImage imageNamed: @"i_launcher.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
    self.navigationItem.titleView = imageView;
    [imageView release];
}
Run Code Online (Sandbox Code Playgroud)

我无法理解为什么图像没有被添加.我该如何添加它?

iphone xcode uinavigationbar

2
推荐指数
2
解决办法
2万
查看次数

Facebook登录app xcode?

我见过很多人一直在问这个问题,但我很困惑...我想在我的iphone应用程序中集成facebook登录.我需要提供登录选项,即登录我们的网站帐户或Facebook登录并使用我们的应用程序.但我有通过谷歌,发现提供Facebook登录功能的教程与总访问(如发布,更新等),即登录Facebook和各自的facebook活动.但我不需要所有这些.我只需要用户登录的功能facebook帐户和访问我们的应用程序.还有一件事我见过从git下载facebook sdk并复制FBConnect文件夹.但是它里面没有这样的文件夹.我很困惑

我在哪里可以找到符合我特定标准的最佳教程..?

请指导我这方面.

iphone xcode facebook facebook-login

1
推荐指数
1
解决办法
8914
查看次数

class不是键值导航栏的符号密码值

我已经将UINavigationbar和UIscrollView添加到UIView(SecondView).当我在firstView中单击一个按钮时,它应该带我到secondView.点击按钮:

 SecondView *secondview=[[SecondView alloc]initWithNibName:@"SecondView" bundle:nil];
 [self presentModalViewController: secondview animated:NO]; //error at this line 
 [secondview release];
Run Code Online (Sandbox Code Playgroud)

在secondView.h中

@property(nonatomic,retain)IBOutlet UINavigationBar *navigationBar;
@property(nonatomic,retain)IBOutlet UIScrollView *testscroll;
Run Code Online (Sandbox Code Playgroud)

SecondView.m:

@synthesize navigationBar,testscroll;
Run Code Online (Sandbox Code Playgroud)

但我得到的错误如下:

由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:SecondView setValue:forUndefinedKey:]:此类不是键值navigationBar的键值编码兼容.

我的secondView.xib是这样的:

无法理解我哪里出错了?

iphone xcode uinavigationbar

0
推荐指数
1
解决办法
4616
查看次数