好吧,这将是一个非常令人尴尬的问题,但我在初学者的书中看起来很疯狂(特别是那些通常有用的指数)并且,我没有找到一个脚踏实地的解释'超级'在我的应用.
我在这看看这个,但我担心这远远超出我.任何人都可以提供一个非常简单的解释,说明我的应用程序中有什么"超级",以及为什么我应该成为它的朋友?例如:
- (void)viewDidLoad {
[super viewDidLoad];}
Run Code Online (Sandbox Code Playgroud)
谢谢!!
我有一个非常基本的初学者关于我动画的UIViews位置的问题.
如果我这样称呼
[pageShadowView setFrame:CGRectOffset([pageShadowView frame], 100, 0)];
Run Code Online (Sandbox Code Playgroud)
然后动画这个
[pageShadowView setFrame:CGRectOffset([pageShadowView frame], -100, 0)];
Run Code Online (Sandbox Code Playgroud)
我基本上会将我的UIView从屏幕右侧移到左侧.但是,如果我在第二行代码中指定-150,并且如果我要重复这些动画几次,我的对象将逐渐向左移动.
这是一个非常基本的问题,我担心,但有没有办法指定固定的X坐标而不是定义相对位置?也就是说我总是希望将对象从x = 200移动到x = 100.
我的整个方法看起来像这样:
[pageShadowView setFrame:CGRectOffset([pageShadowView frame], 100, 0)];
[UIView beginAnimations:@"shadowMove" context:nil]; // Begin animation
[UIView setAnimationDuration:2.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[pageShadowView setFrame:CGRectOffset([pageShadowView frame], -100, 0)];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud) 我有一个字符串(包含一个月),并想检查它是一个'短'月(根据名称的长度)还是'月'名称.根据名称的长度,我想设置它的位置:
NSString* dateMonth = @"SEPTEMPER";
if (dateMonth == @"MARCH" || @"APRIL" || @"MAY" || @"JUNE" || @"JULY") {
CGRect calendarFrame = CGRectMake(170+100, 8, 200, 50);
calendar1 = [[UIView alloc] initWithFrame:calendarFrame];
calendar1.clipsToBounds = true;
} else {
CGRect calendarFrame = CGRectMake(170, 8, 200, 50);
calendar1 = [[UIView alloc] initWithFrame:calendarFrame];
calendar1.clipsToBounds = true;
}
Run Code Online (Sandbox Code Playgroud)
这种情况最终应该在ELSE函数中,但它不会...我最终得到170 + 100的位置.
我究竟做错了什么?任何帮助将非常感谢.
一个菜鸟问题.我正在整理我的第一个数据库并遇到以下设计问题:我有一个定义书籍的类(例如它的标题)和一个定义页面的类(例如它的设计).
课本表看起来如此:
Title | PAGE1 | PAGE2 | PAGE3
Book-One | SAMPLE1-UUID | SAMPLE2-UUID | SAMPLE3-UUID
Book-Two | SAMPLE4-UUID | SAMPLE5-UUID | SAMPLE6-UUID
Run Code Online (Sandbox Code Playgroud)
类页面的表格:
UUID | FONT | CONTENTS etc.
SAMPLE1-UUID | Times | Example
SAMPLE2-UUID | Arial | Example Two
SAMPLE3-UUID | Verdena | Example Three
Run Code Online (Sandbox Code Playgroud)
现在,由于每个页面都是唯一的,并且无法在另一本书中重复使用,因此我不能对Pages使用多对多关系.我可以使用Foreign-Key链接两个表,即将Books表的SAMPLE1-UUID与Pages表的SAMPLE1-UUID链接.这样做的好处是不会两次创建相同的条目.
但是,我不喜欢为我的页面设置固定数量的行.在上面的Book类示例中,我必须定义一组特定的页面,如PAGE1,PAGE2,PAGE3,PAGE4,... PAGE99.理想情况下,我需要的只是我的书类的灵活页面列表,如下所示:
Name | Pages
Book-One | "SAMPLE1-UUID, SAMPLE2-UUID"
Book-Two | "SAMPLE4-UUID, SAMPLE5-UUID, SAMPLE6-UUID"
Run Code Online (Sandbox Code Playgroud)
Pages将是一个简单的CharField,其内容将是一个列表.但后来我遇到了这两个表不再链接的问题,我必须创建两次每个条目(即我必须在页面和书籍表中输入SAMPLE1-UUID).
有没有其他方法来设计这个数据库?谢谢你的任何建议!
我试图将NSString转换(或复制?)为NSMutableArray.我想我的问题是我并不真正了解MutableArray的结构.在我有限的知识中,数组可能如下所示:
NoteBook = [[NSMutableArray alloc] init];
for (int temp = 0; temp < 3; temp++) {
[NoteBook insertObject:@"Page" atIndex:temp];
}
Run Code Online (Sandbox Code Playgroud)
哪个会给我一个PagePagePage数组.我们假设我想打开一个包含PagePagePage的txt文件,但是这些单词被一个已定义的字符串分开,这样我就可以将我的数组中的各个对象分开,如下所示:Page ---页面末尾--- Page- - 页面末尾---页面.
现在,我的下一步是从txt文件中读取此信息:
NSString *tempTextOut = [NSString stringWithContentsOfFile:filePath
encoding:NSUTF8StringEncoding
error:&error];
NoteBook = [tempTextOut componentsSeparatedByString: @"\n--- end of page ---\n"];
Run Code Online (Sandbox Code Playgroud)
但是,最后一行不起作用,我告诉xCode:不兼容的Objective-C类型分配'struct NSArray*',期望'struct NSMutableArray*'.我真的不明白这一点 - NSArray和MutableArray应该是兼容的(因为一个是另一个的子类).不应该xCode告诉我问题是我一直在尝试将NSString转换为NSMutableArray吗?
我可能需要在重新设置MutableArray之前重新设置它,因为现在它仍然包含我在第一步中分配给它的PagePagePage.我以为我的NoteBook可变数组会简单地被字符串替换,但我想情况并非如此.
我非常感谢这件事的任何帮助.谢谢!
这是一个绝对的初学者的问题(对不起),但我想知道如何提交一个动画,一旦它已经结束,开始另一个动画.想象一下,图像从x = 0移动到x = 300.然后你想再次为同一个图像设置动画,但这次从x = 300到x = 330,这样它就会从屏幕上消失.
以下代码仅执行从x = 300到x = 330的动画,并且不会将动画x = 0提交到x = 300.我确信我没有得到commitAnnimation的概念,这是显而易见的,但我将如何在彼此之后做两个动画?
我知道我可以直接将图像移动到330,但我不想要这个,因为我需要第一个动画(x 0 - 300)与另一个动画同步.
这是我的(错误的)代码:
[UIView beginAnimations:@"shadowMove" context:nil]; // Begin animation
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[imageView setFrame:CGRectOffset([imageView frame], 300, 0)];
[UIView commitAnimations]; // End animations
// Second Animation
[UIView beginAnimations:@"shadowMoveRestAway" context:nil]; // Begin animation
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[imageView setFrame:CGRectOffset([imageView frame], 330, 0)]; // Move imageView off screen
[UIView commitAnimations]; // End animations
Run Code Online (Sandbox Code Playgroud) 对不起,这是非常基本的,但是我无法将AnimationOption从默认设置(EaseIn)设置为CurveLinear.这是我根据我在其他线程中读到的内容尝试的:
-(void)animationShadow;
{
[UIView animateWithDuration:4
options:UIViewAnimationOptionCurveLinear
animations:^{
...
Run Code Online (Sandbox Code Playgroud)
如果我拿出选项位,一切正常.如果没有,它会崩溃.我确定我没有拨打正确的命令.
这是整个块动画:
-(void)animationShadow;
{
[UIView animateWithDuration:4
options:UIViewAnimationOptionCurveLinear
animations:^{
//UIViewAnimationOptionCurveLinear
// animation 1
[pageShadowView setTransform:CGAffineTransformMakeScale (3, 1)];
[pageShadowView setFrame:CGRectMake(0-350, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
[UIView beginAnimations:@"pageCurlRightToLeftFinished" context:nil]; // Begin animation
//[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[pageShadowView setFrame:CGRectMake(0-280, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
[UIView commitAnimations];
} completion:^(BOOL finished){ ...
Run Code Online (Sandbox Code Playgroud)
编辑:
好的,我现在更新了这个,但如果我做第二个动画,我仍然会崩溃.我收到警告:UIView可能无法响应+ animateWithDuration ......:
- (无效)animationShadow; {
[pageShadowView setTransform:CGAffineTransformMakeScale (3, 1)];
[pageShadowView setFrame:CGRectMake(0-350, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
[UIView animateWithDuration:kPageCurlSpeed/4
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
[pageShadowView setFrame:CGRectMake(0-280, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
}
completion:^(BOOL finished){
[UIView animateWithDuration:kPageCurlSpeed
delay:0 …Run Code Online (Sandbox Code Playgroud) 我有一个方法,我分配和初始化
UIView (`tabsClippedView = [[[UIView alloc] initWithFrame:tabsClippedFrame] autorelease];`).
Run Code Online (Sandbox Code Playgroud)
此视图添加了另一个视图
(`tabsView = [[[UIView alloc] initWithFrame:tabsFrame] autorelease];`).
Run Code Online (Sandbox Code Playgroud)
然后我发起几个按钮
(e.g. `UIButton* btn = [[[UIButton alloc] initWithFrame:frame] autorelease];`)
Run Code Online (Sandbox Code Playgroud)
并将它们添加到视图的子视图中.
现在,我需要删除所有按钮并再次分配它们.是删除整个视图的最佳方法还是仅添加按钮的子视图?
我怎么需要这样做(没有内存泄漏等)?会很简单
self.tabsView = nil;
Run Code Online (Sandbox Code Playgroud)
是否足以删除视图及其所有子视图(即按钮)?
或者更好的是删除超级视图,从头开始:
self.tabsClippedView = nil;
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中有一个NSMutableArray,我这样启动:
H-FILE
NSMutableArray *noteBookContent;
@property (nonatomic, retain) NSMutableArray *noteBookContent;
Run Code Online (Sandbox Code Playgroud)
M-FILE
@synthesize noteBookContent;
Run Code Online (Sandbox Code Playgroud)
然后我有一个方法,我打开一个txt文件并将其内容读入临时NSString并将此NSString切片到不同的位,然后将其放入NSMutableArray.像这样:
NSString *tempTextOut = [NSString stringWithContentsOfFile:filePath
encoding:NSUTF8StringEncoding
error:&error];
self.noteBookContent = [[[tempTextOut componentsSeparatedByString: @"\n[DIVIDER]\n"] mutableCopy] autorelease];
Run Code Online (Sandbox Code Playgroud)
我的大问题是如果我重复相同的过程几次会发生什么.在我将新数据读入之前是否需要发布noteBookContent?是否存在数据混乱的可能性,例如,如果一个noteBookContent有10个项目(全部称为FRUIT)而下一个noteBookContent有5个项目(全部称为SALAD),我最终可能会得到SALAD,SALAD,SALAD,SALAD,SALAD,水果,水果,水果,水果等?
很抱歉,如果这很明显,但我真的不明白当我将新数据读入已包含旧数据的NSMutableArray时会发生什么.
谢谢你的解释!
好吧,以前一定要问这个但是我看起来很生气,一无所获:
我在我的iphone应用程序中有一个简单的数组,我这样定义:
@property (nonatomic, strong) NSArray *pages;
@synthesize pages = _pages;
Run Code Online (Sandbox Code Playgroud)
我在Apples示例代码中看到了这一点,并且认为这是编写self.pages(即_pages替换self.pages)的一个很好的捷径,如下所示:
_pages = [[NSArray alloc] init];
Run Code Online (Sandbox Code Playgroud)
但是Apple再次拥有它(不完全像这样,但看起来好像他们一直随机交换):
self.pages = [NSKeyedUnarchiver unarchiveObjectWithData:contents];
Run Code Online (Sandbox Code Playgroud)
最后:
[_pages release];
Run Code Online (Sandbox Code Playgroud)
这完全让我感到困惑._pages和self.pages之间会有什么区别?
谢谢你的帮助.
iphone ×9
cocoa-touch ×8
objective-c ×7
animation ×3
uiview ×3
database ×1
django ×1
if-statement ×1
ios ×1
nsstring ×1
postgresql ×1
self ×1
super ×1