我刚刚安装了支持iOS6的Xcode 4.5,我在Storyboard中看到了一个名为"Exit"的新图标,列在我的视图控制器下面,还有"First Responder"等.一个标有"Exit"的绿色小图标.
我可以在它上面找到任何东西,也不知道如何使用它.
任何人都知道它,它是如何工作的,它的用途是什么?
在WWDC 2010 的iPhone示例代码" PhotoScroller "中,他们展示了如何通过滚动,缩放和分页图像来完成照片应用程序的相当好的模仿.他们还平铺图像以显示如何显示高分辨率图像并保持良好性能.
通过抓取不同分辨率的预缩放和剪切图像并将它们放置在构成整个图像的网格中,在示例代码中实现平铺.
我的问题是:有没有办法平铺图像而无需手动浏览所有照片并创建"图块"?照片应用程序如何能够动态显示大图像?
编辑 以下是Deepa的答案代码如下:
- (UIImage *)tileForScale:(float)scale row:(int)row col:(int)col size:(CGSize)tileSize image:(UIImage *)inImage
{
CGRect subRect = CGRectMake(col*tileSize.width, row * tileSize.height, tileSize.width, tileSize.height);
CGImageRef tiledImage = CGImageCreateWithImageInRect([inImage CGImage], subRect);
UIImage *tileImage = [UIImage imageWithCGImage:tiledImage];
return tileImage;
}
Run Code Online (Sandbox Code Playgroud) 我想在我的UINavigationBar中有一个titleView,它有两行文本而不是一行
当我有一个"Back"-Button和一个"Edit"按钮时,我当前的实现效果很好,因为它看起来几乎居中.问题是我只有一个按钮.它看起来非常奇怪和错误,因为视图集中在可用空间上.
这是我目前的实施:
CGRect frame = self.navigationController.navigationBar.frame;
UIView *twoLineTitleView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetWidth(frame), 0, CGRectGetWidth(frame), CGRectGetHeight(frame))];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 8, CGRectGetWidth(frame), 14)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.text = self.title;
[twoLineTitleView addSubview:titleLabel];
UILabel *subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 23, CGRectGetWidth(frame), 14)];
subTitleLabel.backgroundColor = [UIColor clearColor];
subTitleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
subTitleLabel.textAlignment = UITextAlignmentCenter;
subTitleLabel.text = self.subTitle;
[twoLineTitleView addSubview:subTitleLabel];
self.navigationItem.titleView = twoLineTitleView;
Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的问题,我正在请求一个URL,我想从中获取cookie,我用这种方式来获取cookie:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response;
NSDictionary *fields = [HTTPResponse allHeaderFields];
NSString *cookie = [fields valueForKey:"Set-Cookie"];
}
Run Code Online (Sandbox Code Playgroud)
但是饼干不完整,有一些字段缺失,我在PostMan上检查过,所有的饼干都在那里.
我在启动时也使用了这种方法NSURLRequest.
[request setHTTPShouldHandleCookies:YES];
Run Code Online (Sandbox Code Playgroud)
问题出在哪儿?
注意:这个问题是在iOS上,我是一个Android版本,它工作正常,所有的cookie都在那里.
我试图用特定的图像替换典型的iOS mapkit"pin".我是编码的新手,所以我不确定为什么这不起作用,但这是我尝试过的:
对于该方法
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
Run Code Online (Sandbox Code Playgroud)
除此之外,我还有:
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
//pinView.pinColor=MKPinAnnotationColorPurple;
UIImage *pinImage = [UIImage imageNamed:@"Jeff.png"];
[pinView setImage:pinImage];
Run Code Online (Sandbox Code Playgroud)
但是,即使代码编译得很好,pinView也没有设置pinImage.任何想法为什么不呢?
我创建了一个新的cocos2d项目,并将之前项目中的一些文件复制到这个新项目中.我确保在xCode提示时表明我想要一份副本.我的AppDelegate类是AppDelegate.
我做了一个干净的新项目的构建.
我的main.m看起来像这样
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
[pool release];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
当我运行新项目时,我收到以下错误;
无法实例化UIApplication委托实例.没有加载名为AppDelegate的类.
当出现此错误时
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
Run Code Online (Sandbox Code Playgroud)
正在main.m文件中运行.
AppDelegate类显然存在于我的项目中.我希望有人能在这里朝着正确的方向推动我.
我可以知道如何UILable仅使用阴影添加底部边框?没有顶部,左侧,右侧边框.
这不起作用.这是我尝试过的代码,但它不起作用.
CALayer* layer = [titleLabel layer];
layer.frame = CGRectMake(-1, -1, titleLabel.frame.size.width, 1.0f);
layer.borderWidth=1;
[layer setBorderWidth:2.0f];
[layer setBorderColor:[UIColor blackColor].CGColor];
[layer setShadowOffset:CGSizeMake(-3.0, 3.0)];
[layer setShadowRadius:5.0];
[layer setShadowOpacity:5.0];
Run Code Online (Sandbox Code Playgroud) 我正在设计一个IPhone应用程序.用户搜索的东西.我们从网上获取数据.然后我们更新表格.
伪代码就是
[DoThisAtbackground ^{
LoadData ();
[DoThisAtForeground ^{
UpdateTableAndView();
}];
}];
Run Code Online (Sandbox Code Playgroud)
如果在第一次搜索完成之前用户搜索其他内容呢?
解决这个问题的行业标准方法是什么?
我们究竟是怎么做到的?
我对内部分发和临时分发感到困惑.
内部和临时分发应用程序是否需要让苹果审核小组进行审核?
内部分配和临时分配有何不同?
用于创建内部应用程序证书和分发流程的任何示例/指南行?
内部分发是否需要收集用户UDID进行配置?
如果我开始使用内部/ ad-hoc分发分发"A"应用程序,我可以稍后将"A"应用程序分发到App Store吗?
我正在尝试构建一个使用图层的应用程序,我的应用程序结构是
UIView --> UIScrollView --> UIView --> LayersView (Custom UIView)
--> UIImageView
Run Code Online (Sandbox Code Playgroud)
我想多层添加到LayersView,所以我建立一个自定义CALayer使用UIBezierPath绘制一组点.
CALayerBezierPath.h
#import <QuartzCore/QuartzCore.h>
@interface CALayerBezierPath : CALayer {
NSMutableArray *pointsArray;
}
@property (nonatomic, retain) NSMutableArray *pointsArray;
- (void) initVariables;
- (void) addNewPoints:(CGPoint)newPoint;
@end
Run Code Online (Sandbox Code Playgroud)
CALayerBezierPath.m
#import "CALayerBezierPath.h"
@implementation CALayerBezierPath
@dynamic pointsArray;
-(void)drawInContext:(CGContextRef)ctx {
NSLog(@"CALayerBezierPath - drawInContext");
if ([pointsArray count] > 0) {
UIColor *color = [UIColor redColor];
[color set];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:[[pointsArray objectAtIndex:0] CGPointValue]];
for (int x = 1; x …Run Code Online (Sandbox Code Playgroud) ios ×5
objective-c ×5
iphone ×3
calayer ×2
xcode ×2
annotations ×1
cgcontext ×1
cookies ×1
image ×1
ios5 ×1
ipad ×1
mapkit ×1
nsurlrequest ×1
quartz-core ×1
storyboard ×1
tiles ×1
titleview ×1
uilabel ×1
uiscrollview ×1
web-services ×1