我知道这是一个非常常见的问题,但每个网站上的所有答案都不起作用!如果您仍然不知道我的意思,那么这行代码可能会帮助您理解.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if (touch.view == nextbutton)
[self performSelector:@selector(next)];
if (touch.view == prevbutton)
[self performSelector:@selector(previous)];
if (touch.view == moreoptionsbutton)
[self performSelector:@selector(moresettings)];
}
Run Code Online (Sandbox Code Playgroud)
当你触摸nextbutton, prevbutton, and more optionsbutton它时它什么都不做,UIImageViews顺便说一下.我也尝试使用isEqual:而不是==,但这也没有成功.有什么建议?
是的,本世纪的noob问题......但是说实话,我实际上不知道浮点值到底是什么......更重要的是,浮点数和整数之间的差异.
提前致谢!
我的应用程序涉及用户能够拖动特定项目,如音量滑块和UIImage视图.我的目标是能够保存项目的位置,以便用户在重新启动后不必再次拖动项目.不幸的是,我看到了"保存CGRect rect = item.frame到NSuserDefaults或NSKeyedArchiver"路线的错误.还有其他建议吗?
我的应用程序涉及音乐(iPodMusic),还有一个UISwitch切换播放/暂停.我的目标是能够检测音乐是否正在播放,因此播放/暂停开关可以在播放音乐时说"播放",如果不播放则说"暂停".
我很惊讶我找不到这个简单任务的答案.我只是希望用户键入文本,按回车键,让应用程序知道他/她键入的内容.我该怎么做?
在JavaScript中,我想定义小数位的位置.我只能在例子中展示它.
让我们说输入值是1234.
我想要输出123.4.
或者,如果输入是12345,我想要输出123.45.
或者,如果输入是123456,我想要输出123.456.你得到了照片.
为了澄清,我只想在小数的左边有三位数.总位数未知.
那么,怎么办呢?
就像练习一样,我正在研究一个解决着名的中学毕达哥拉斯定理的应用程序,一个平方+ b平方= c平方.不幸的是,在我看来,即将出现的答案与实际答案无关.这是"解决"操作期间使用的代码.
- (IBAction)solve {
int legoneint;
int legtwoint;
int hypotenuseint;
int lonesq = legoneint * legoneint;
int ltwosq = legtwoint * legtwoint;
int hyposq = hypotenuseint * hypotenuseint;
hyposq = lonesq + ltwosq;
if ([legone.text isEqual:@""]) {
legtwoint = [legtwo.text intValue];
hypotenuseint = [hypotenuse.text intValue];
answer.text = [NSString stringWithFormat:@"%d", legoneint];
self.view.backgroundColor = [UIColor blackColor];
}
if ([legtwo.text isEqual:@""]) {
legoneint = [legone.text intValue];
hypotenuseint = [hypotenuse.text intValue];
answer.text = [NSString stringWithFormat:@"%d", legtwoint];
self.view.backgroundColor = [UIColor blackColor];
}
if …Run Code Online (Sandbox Code Playgroud) iphone ×3
audio-player ×1
cocoa ×1
decimal ×1
enter ×1
integer ×1
ios ×1
javascript ×1
math ×1
move ×1
pythagorean ×1
return ×1
text ×1
touchesbegan ×1
uiimageview ×1
uiswitch ×1
uitouch ×1