小编Ven*_*enk的帖子

虽然contentSize小于UIImageView,但UIScrollView不滚动

所以我有一个UIImageView子视图UIScrollView,我设置contentSize为小于UIImageView宽度和高度,但它不允许我滚动..为什么这?这是一些代码:

UIImage * image = [UIImage imageWithData:data];
                UIImageView * imgView = [[UIImageView alloc] initWithImage:image];
                [imgView setUserInteractionEnabled:YES];
                //[imgView setContentMode:UIViewContentModeScaleAspectFill];
                [imgView setBackgroundColor:[UIColor clearColor]];
                [imgView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
                [imgView setFrame:CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height)];

                CGRect imgFrame;
                imgFrame.size.width = originalImageSize.width;
                imgFrame.size.height = originalImageSize.height;
                imgFrame.origin.x = imageOriginPoint.x;
                imgFrame.origin.y = imageOriginPoint.y;

                UIScrollView * imgScrollView = [[UIScrollView alloc] initWithFrame:imgFrame];
                [imgScrollView setScrollEnabled:YES];
                [imgScrollView setClipsToBounds:YES];
                [imgScrollView addSubview:imgView];
                [imgScrollView setBackgroundColor:[UIColor clearColor]];


  [imgScrollView setFrame:imgFrame];
                [imgScrollView setContentSize:CGSizeMake(200, 200)];

SCROLL VIEW CONTENT SIZE WIDTH IS 200.000000 …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiscrollview ipad ios

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

addChildViewController和presentViewController

iOS 5介绍了自定义容器视图控制器的概念,并提供了类似的API addChildViewController.问题:您可以将视图控制器添加为子视图并仍然使用它presentViewController吗?做后者会自动使它成为子视图控制器presentingViewController吗?

uiviewcontroller ios5

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

用MKMapView显示当前用户位置?

我试图通过的属性设置来显示用户的当前位置MKMapViewsetShowsUserLocationYES.默认情况下,当应用程序开始更新用户位置时,iPhone屏幕左上方会出现一个箭头.但是在显示当前位置后,箭头应该消失,但只要应用程序正在运行,它仍然存在,这意味着应用程序仍处于静止状态在后台更新位置?那我怎么能停止更新当前位置?我已经实现了立即调用的委托..

iphone mapkit ios

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

Objective-C:对包含NSMutableArrays的NSMutableArray进行排序

我目前正在使用NSMutableArrays我的开发来存储从HTTP Servlet获取的一些数据.

一切都很好,因为现在我必须对我的数组中的内容进行排序.

这就是我做的:

NSMutableArray *array = [[NSMutableArray arrayWithObjects:nil] retain];
[array addObject:[NSArray arrayWithObjects: "Label 1", 1, nil]];
[array addObject:[NSArray arrayWithObjects: "Label 2", 4, nil]];
[array addObject:[NSArray arrayWithObjects: "Label 3", 2, nil]];
[array addObject:[NSArray arrayWithObjects: "Label 4", 6, nil]];
[array addObject:[NSArray arrayWithObjects: "Label 5", 0, nil]];
Run Code Online (Sandbox Code Playgroud)

第一列包含Label,第二列是我希望数组按降序排序的分数.

我存储数据的方式是好的吗?有没有更好的办法做到这一点比使用NSMutableArraysNSMutableArray

我是iPhone开发人员的新手,我看过一些关于排序的代码,但对此并不满意.

提前感谢您的回答!

sorting objective-c nsmutablearray

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

为什么即使在设置委托协议后也没有调用UIPickerView委托方法?

`我正在创建一个UIPickerView,它不会从数组中获取数据,因为没有调用委托方法.我设置了UIPickerviewdelegate和datasource但是它仍然没有工作.可能是没有调用委托方法的原因?????如果有人知道它请告诉我.谢谢你.

picker.delegate=self;
picker.dataSource=self;



arrayOfState = [[NSMutableArray alloc] init];
[self.arrayOfState addObject:@"Assam"];
[arrayOfState addObject:@"Andhra Pradesh"];
[arrayOfState addObject:@"Madhya Pradesh"];
[arrayOfState addObject:@"West Bengal"];
[self.arrayOfState addObject:@"Orissa"];    
[self.arrayOfState addObject:@"Meghalaya"];
[arrayOfState addObject:@"Tripura"];
[arrayOfState addObject:@"Arunachal Pradesh"];  
[arrayOfState addObject:@"Jammu and Kashmir"];  

picker=[[UIPickerView alloc] initWithFrame:CGRectMake(0.0f,100.0f,40.0f,120.0f)];
picker.showsSelectionIndicator=YES;
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

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

GMGridView选择是最重要的

在此输入图像描述在此输入图像描述我使用GMGridView时遇到了奇怪的问题.其实我用GMGridview来展示餐厅餐桌.如果我选择Table1(这意味着第一个单元格),它应该更改为redColor(这意味着它是被占用的表).我做了这个,但我的问题是当我选择一个单元格1(红色)时,所有类别中都会显示红色,而不管我使用GMGridview.这是完全错误的,没有在另一个类中进行任何选择,它显示为选定的一个.

在下面的图像中,如果我选择了1,它显示7也被选中.....

我的代码是

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index{



    CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication 
sharedApplication] statusBarOrientation]];


    GMGridViewCell *cell = [gridView dequeueReusableCell];


    int isOccupied = [[[self.arrayOfoccupiedTables objectAtIndex:index] objectForKey:@"TStatus"] intValue];


    if (!cell)

    {

        cell = [[[GMGridViewCell alloc] init] autorelease];


        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];

        cell.contentView = view;

    }


    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];


    UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];

    label.autoresizingMask = UIViewAutoresizingFlexibleWidth | 

UIViewAutoresizingFlexibleHeight;

    label.textAlignment = UITextAlignmentCenter;

    label.backgroundColor = [UIColor clearColor];

    label.font = [UIFont fontWithName:APPFONTLI size:22.0f];

    label.adjustsFontSizeToFitWidth = YES;



    if …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios gmgridview

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

UIActionSheet showFromRect Autorotation

我是UIActionSheet这样的:

-(void)accessoryPressed:(id)sender{
    //Omitted unnecessary objects

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:titleString delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"Upload", nil];
    //actionSheet.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    actionSheet.tag = ((UIButton*)sender).tag;
    [actionSheet showFromRect:[(UIButton*)sender frame] inView:[(UIButton*)sender superview] animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

sender对象是一个UIButton嵌入在一个UITableViewCell的附件图.

问题是,当iPad旋转时,动作表没有调整大小(我不希望它实际调整大小但我希望它在正确的X,Y中)我尝试将AutoResizingMask设置为FlexibleLeft和FlexibleTop但它没有似乎改变了.

有没有人知道如何让actionSheet指向accessoryView自动旋转后?

这是它的样子:

在轮换之前 - 在轮换之前

轮换后 - 在此输入图像描述

ios ios5

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

UITableView滚动方向

无论如何要知道a UITableView是否向桌面的上端或下端滚动?

iphone sdk uitableview

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

修剪NSString中的空格

我有NSString @" (\n "Bi_ss" \n) " 想要获得String @"Bi_ss "

有谁对此有任何想法?谢谢

iphone nsstring

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

iOS:在didFinishLoad之后调整UIWebView(内容应该适合而不滚动)

我绝对无法调整我的大小UIWebView.

UIWebView的声明是在.h和IB中连接的.IB中的高度是110.但是我的文本高度大约是1500.现在我想改变高度,这样全文就可以读取而不需要滚动.

什么代码调整了我UIWebView的内容webViewDidFinishLoad?找不到任何有效的东西.

height xcode uiwebview ios

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