我整天都在阅读这篇文章,根本无法解决问题.我正在尝试加载一个网页,并在完成加载后自动将其滚动到预先确定的点.我一直在阅读教程,如http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview,但仍然没有运气.
这是我的.m问题出现的地方.我很绝望请帮忙!另外,它告诉我我的webViewDidFinishLoad正在覆盖实例变量,但这应该不是我认为的问题
- (void)viewDidLoad {
[super viewDidLoad];
NSString *urlAddress = @"http://www.twitter.com/richrines";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
// Do any additional setup after loading the view from its nib.
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[webView stringByEvaluatingJavaScriptFromString:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function myFunction() { "
"window.scrollTo(100,100)"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);"];
[webView stringByEvaluatingJavaScriptFromString:@"myFunction();"];
}
Run Code Online (Sandbox Code Playgroud) 出于某种原因,当我传入表单数据时,它将保存到数据库中为nil.我正在使用rails 4并使用强大的参数,根据服务器一切看起来不错,但最终它最终节省为零.非常感谢所有的帮助,我是铁杆的新手,这个让我难过.我目前还没有在模型中进行任何验证,试图让它工作.
控制器代码
def create
@movie = Movie.new(params[movie_params])
if @movie.save
redirect_to @movie
else
flash[:error] = "Didn't save"
render 'new'
end
end
private
def movie_params
params.require(:movie).permit(:title, :rating)
end
表格代码
<%= form_for(@movie) do |f| %>
<%= f.label :title %>
<%= f.text_area :title %>
<%= f.label :rating %>
<%= f.text_area :rating %>
<%= f.submit "Submit" %>
<% end %>
我试图向float我的游戏中心排行榜提交两位小数长度,但是唯一允许提交的格式是int64_t.我使用默认的Apple报告分数方法:
- (void)reportScore:(int64_t)score forCategory:(NSString *)category {
GKScore *scoreReporter = [[GKScore alloc] initWithCategory:category];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler: ^(NSError *error) {
[self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
}];
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用此方法为报表分数方法提供分数:
- (IBAction)increaseScore {
self.currentScore = self.currentScore + 1;
currentScoreLabel.text = [NSString stringWithFormat: @"%lld", self.currentScore];
NSLog(@"%lld", self.currentScore);
}
Run Code Online (Sandbox Code Playgroud)
请帮忙,我一直在谷歌上搜索疯狂,无法找到答案.
objective-c ×2
forms ×1
game-center ×1
gamekit ×1
gkscore ×1
ios ×1
iphone ×1
javascript ×1
uiwebview ×1