int cinema,dvd,pc,total;
double fractionCinema, fractionOther;
fractionCinema=(cinema/total)*100; //percent cinema
Run Code Online (Sandbox Code Playgroud)
因此,当我运行代码来显示fractionCinema时,它只给我零.如果我将所有的整数改为双打,那么它就会给我我想要的东西.但是,我在其他地方使用电影,电脑和总数,它们必须显示为整数,而不是小数.我该怎么办?
我有一个UITableView.我在此表中添加了一个UIGestureRecognizer,用于查找单元格上的滑动,并在检测到滑动时启用对该表的编辑.当我向右滑动时,确实可以在桌面上进行编辑.但是,当我向左滑动时,我会在单元格的右侧显示默认的红色删除按钮.如何禁用此默认行为,并使其如果我向左或向右滑动,我会在任何一种方式进行编辑?
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
foldersTable.editing=YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[foldersTable addGestureRecognizer:recognizer];
[recognizer release];
}
Run Code Online (Sandbox Code Playgroud) 所以我正在读取一个文件的输入,该文件说这些行:
NEO
You're the Oracle?
NEO
Yeah.
Run Code Online (Sandbox Code Playgroud)
所以我只想输出他的实际线,而不是它所说的NEO.所以我尝试了这个:
if(line.trim()=="NEO")
output=false;
if (output)
TextIO.putln(name + ":" + "\"" + line.trim() + "\""); // Only print the line if 'output' is true
Run Code Online (Sandbox Code Playgroud)
但那没有成功.它仍然打印NEO.我怎样才能做到这一点?
我有一个UITextView,我实现了一个keyboardWasShownMethod,如下所示:
(void)keyboardWasShown:(NSNotification*)aNotification {
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGRect bkgndRect = inkTextField.superview.frame;
bkgndRect.size.height += kbSize.height;
[inkTextField.superview setFrame:bkgndRect];
[inkScroller setContentOffset:CGPointMake(0.0, inkTextField.frame.origin.y-kbSize.height) animated:YES];
inkTextField.frame=CGRectMake(1, -5, 285, 221);
NSLog(@"Called keyBoardWasShwon");
}
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,当我的键盘出现时它不会被调用.此方法与UITextView位于同一类中,UITextView在.h文件中声明并在XIB中连接.可能是什么原因造成的?
假设已经声明了int变量i和j,并且已经声明并初始化了n.
使用for循环(可能需要多个),编写将导致大小为n的三角形的三角形输出到屏幕的代码.
例如,如果n的值为4,则输出应为
*
**
***
****
Run Code Online (Sandbox Code Playgroud)