我即将创建一个App.
它应该有3个主页.所以我想到了用PageControl实现这个目标.
我创建了3个视图,现在我被困在这个PageControl的实现上.
有没有人可以看一下好的教程或示例代码(它也可以是德语)?
谢谢,迈克尔
例如,我试图通过fadein将cell.accessoryView从picture1更改为picture2
但我的问题是我只有一个accessoryView(一个UIView)
任何的想法?
很难说我上传图片来显示我的问题:http://i42.tinypic.com/2eezamo.jpg
基本上在drawRect中,我将从touchesMoved中绘制线条作为手指触摸,我将调用"needsDisplayInRect"进行重绘.但是我发现第一行已经完成,第二行将清除rect部分,因此一些previouse绘图已经消失.
这是我的实现:
enter code here
-(void) drawRect:(CGRect)rect{
//[super drawRect: rect];
CGContextRef context = UIGraphicsGetCurrentContext();
[self drawSquiggle:squiggle at:rect inContext:context];
}
- (void)drawSquiggle:(Squiggle *)squiggle at:(CGRect) rect inContext:(CGContextRef)context
{
CGContextSetBlendMode(context, kCGBlendModeMultiply);
UIColor *squiggleColor = squiggle.strokeColor; // get squiggle's color
CGColorRef colorRef = [squiggleColor CGColor]; // get the CGColor
CGContextSetStrokeColorWithColor(context, colorRef);
NSMutableArray *points = [squiggle points]; // get points from squiggle
// retrieve the NSValue object and store the value in firstPoint
CGPoint firstPoint; // declare a CGPoint
[[points objectAtIndex:0] …Run Code Online (Sandbox Code Playgroud) 嘿我在我创建的字典中有这些UIView对象:
- (NSArray *)createNumberOfViews:(NSInteger)number
{
NSMutableArray *viewArray = [NSMutableArray array];
for(NSInteger i = 0; i < number; i++)
{
UIView *view = [[UIView alloc] init];
// any setup you want to do would go here, e.g.:
// view.backgroundColor = [UIColor blueColor];
[viewArray addObject:view];
[view release];
}
return viewArray;
}
Run Code Online (Sandbox Code Playgroud)
所以现在我需要访问这个数组的每个成员并将它们各自添加到一个superview,任何想法如何我可以继续这样做?
我在scrollView中有很多不同类的对象.在做一些操作时,我想打印每个对象的父类.我该怎么做?
我已经创建了一个UIView子类和相应的xib文件,其中我已经布置了一些UILabels和UIImageViews.我想将这个自定义UIView的多个副本放入UIViewController.
当我这样做时,它们在界面构建器中显示为空白,并且在应用程序加载时不会显示.我需要在UIView子类上实现哪些方法才能使其工作?
我将最终得到一系列RSS提要,并希望在视图的底部显示标签或其他类似标签.我想为数组中的每个feed设置动画.
这是我到目前为止动画的内容,它适用于淡入淡出,但只能动画数组的最后一项.
feed = [[UILabel alloc] initWithFrame:CGRectMake(0,380,320,43)];
[self.view addSubview:feed];
feed.alpha=1;
NSArray *feeds = [NSArray arrayWithObjects:[NSString stringWithFormat:@"1234567"],[NSString stringWithFormat:@"qwerty"],[NSString stringWithFormat:@"asdfgh"],nil];
for (NSString* f in feeds){
feed.text=f;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:2.0f];
feed.alpha=0;
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
我确定它很简单.
谢谢
我有一个Masterview.it有很多childviews.我使用下面的代码来检测触摸的视图,并带来前面相应的视图.代码工作正常.但是当我将子视图添加到子视图时,它没有工作,任何帮助请?
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
{
self.hitView = nil;
self.hitView = [super hitTest:point withEvent:event];
int x = self.hitView.frame.origin.x;
int y = self.hitView.frame.origin.y;
NSLog(@"x = %d",x);
NSLog(@"y = %d",y);
if ([self.viewDelegate respondsToSelector:
@selector(view:hitTest:withEvent:hitView:)])
{
return [self.viewDelegate view:self hitTest:point
withEvent:event hitView:hitView];
}
else
{
[self bringSubviewToFront:self.hitView];
return hitView;
}
Run Code Online (Sandbox Code Playgroud)
}
我有一个问题,即发布视图的次数太多了.虽然理论上很简单,因为我将uiview移动到uiview,这是uiview的一个子类,并且是动画的,所以它不是我可以轻松修复的东西.它只会在一定条件下崩溃10%,即使在这些条件下也只有30%的时间.
换句话说,它有点复杂.有时在我的dealloc方法中,此UIView的保留计数已经为1(在视图发布时会释放),因此不应再次释放.所以我做的是这样的:
if ([mainView retainCount] > 1) {
NSLog(@"released");
[mainView release];
}
Run Code Online (Sandbox Code Playgroud)
与发布的崩溃一致通常被称为,但并非总是如此,并且当我有时期望它崩溃时它几乎发生.我用这个代码检查了泄漏,它从不泄漏.
现在实际的问题......由于保留计数而释放一些东西是错误的吗?我已经尝试了许多不同的方法来解决这个问题,到目前为止,这是唯一可靠且无泄漏的方法.
编辑:如果没有,那么将一个UIView复制到另一个UIView的更好方法是什么?
mainView = newView;
[newView release];
Run Code Online (Sandbox Code Playgroud)
我尝试先释放mainView,然后在newView上调用copy,但这会崩溃.以上也很有效,除非保留计数有时比预期低1,即使它从未在代码中释放任何其他内容.
我需要为我的视图设置一些背景图像.我怎样才能做到这一点?
uiview ×10
iphone ×8
ipad ×2
objective-c ×2
cgcontext ×1
cocoa-touch ×1
custom-view ×1
drawing ×1
drawrect ×1
init ×1
ios ×1
retaincount ×1
xcode ×1
xib ×1