我有一个使用故事板开发的ios5应用程序,当前在初始启动时显示标签栏控制器视图.我想在显示标签栏控制器之前显示登录屏幕.用户将输入他的用户名和密码,然后系统将对用户进行身份验证,然后如果成功,则显示标签栏控制器.
我已经尝试了以下3个选项但没有运气..任何想法?
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Option 1
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
PointsViewController *firstVC = [[tabBarController viewControllers] objectAtIndex:0];
UIViewController *loginViewController = [[LoginViewController alloc] init];
[firstVC.navigationController pushViewController:loginViewController animated:YES];
// Option 2
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UIViewController *loginViewController = [[LoginViewController alloc] init];
[tabBarController presentViewController:loginViewController animated:NO completion:nil];
// Option 3
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UIViewController *loginViewController = [[LoginViewController alloc] init];
[tabBarController presentModalViewController:loginViewController animated:NO];
return YES;
}
Run Code Online (Sandbox Code Playgroud) 我的控制器中有一个动作,我遇到了麻烦.这是我的第一个rails应用程序,所以我不确定有关rails的最佳实践.
我有一个名为Group的模型和一些控制器中的动作.我编写了一个测试,该测试应该导致控制器因为组ID无效而在JSON中呈现错误.它不是渲染和退出,而是看起来控制器正在渲染并继续执行.
测试
test 'should not remove group because of invalid group id' do
post(:remove, {'group_id' => '3333'})
response = JSON.parse(@response.body)
assert_response :success
assert_equal 'Success', response['message']
end
Run Code Online (Sandbox Code Playgroud)
控制器动作
# Post remove
# group_id
def remove
if((@group = Group.find_by_id(params[:group_id])) == nil)
render :json => { :message => "group_id not found" }
end
@group.destroy
if(!Group.exists?(@group))
render :json => { :message => "Success" }
else
render :json => { :errors => @group.errors.full_messages }
end
end
Run Code Online (Sandbox Code Playgroud)
在控制器中,第一个if语句执行:render :json => { :message …
我正在尝试验证电子邮件地址..它是否存在..以及它是否符合正则表达式标准(/ xyz /).我真的需要在rails中的控制器或视图级别执行此操作,因为我打算为我的应用程序转储ActiveRecord,因为我计划稍后使用nosql数据库.
任何提示?建议?
在模型中,它将是以下代码..但我试图在控制器或视图中执行此操作:
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
Run Code Online (Sandbox Code Playgroud) 出于某种原因,当我在资源1和资源2之间切换时,我的控制器被双重调用.
这是代码:
的index.html
<!DOCTYPE html>
<html ng-app="multiple_calls">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<a href="#res/1">1</a>
<a href="#res/2">2</a>
<div ng-view>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
app.js
var app = angular.module('multiple_calls', []);
app.
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/res/:id', {templateUrl: 'res.html',
controller: 'res'
});
}]);
app.controller('MainCtrl', function($scope) {
});
app.controller('res', function($scope, $routeParams) {
console.log('resource called')
$scope.id = $routeParams.id;
});
Run Code Online (Sandbox Code Playgroud)
res.html
{{id}}
Run Code Online (Sandbox Code Playgroud)
http://plnkr.co/edit/HsCJmbllOcnlvlc1oiHa?p=preview
如果单击项目1然后单击2,您将看到"资源调用"打印3次:资源之间每次更改2次.
任何线索为什么会发生这种情况?
我用karma运行我的角度测试,我的应用程序在浏览器中正常运行,但测试失败,我怀疑设置错误.
以下是控制器和测试:
// app/scripts/controllers/main.js
'use strict';
angular.module('GloubiBoulgaClientApp')
.controller('MainCtrl', function ($scope) {
});
Run Code Online (Sandbox Code Playgroud)
这是测试文件:
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('GloubiBoulgaClientApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('should attach a list of awesomeThings to the scope', function () {
expect(true).toBe(true);
});
});
Run Code Online (Sandbox Code Playgroud)
因果报应
module.exports = function(config) {
config.set({
// base path, that will be used …Run Code Online (Sandbox Code Playgroud) 以下哪种方法被认为是在用户会话期间将数据存储在grails中的推荐方法?
在功能测试中,我想在另一个控制器中调用一个动作.
我一直在寻找更新Route模型的机制,并让Component(在与该路由关联的模板内调用)对该事件作出反应,并重新渲染自身.
所以我有这样的索引模板(我传入了IndexController的模型,据我所知,它只是IndexRoute的代理 - 顺便说一句,我没有定义IndexController):
<script type="text/x-handlebars" id="index">
Below is the bar-chart component
<br/>
{{bar-chart model=model}}
</script>
Run Code Online (Sandbox Code Playgroud)
我有我的组件模板:
<script type="text/x-handlebars" data-template-name="components/bar-chart">
</script>
Run Code Online (Sandbox Code Playgroud)
我的组件是在一个单独的JS文件中实现的,如下所示:
App.BarChartComponent = Ember.Component.extend({
classNames: ['chart'],
model: null,
chart: BarChart(),
didInsertElement: function() {
Ember.run.once(this, 'update');
},
update: function() {
var data = this.get('model').map(function(sales) {
return sales.get('amount');
});
d3.select(this.$()[0]).selectAll('div.h-bar')
.data(data)
.call(this.get('chart'));
}
});
Run Code Online (Sandbox Code Playgroud)
BarChart()函数只返回一个函数对象,该对象执行DOM操作以使用D3生成图形.
我的IndexRoute定义如下:
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('sales');
}
});
Run Code Online (Sandbox Code Playgroud)
在这个实验中,我使用夹具:
App.Sales = DS.Model.extend({
amount: DS.attr('number')
});
idx = 1;
App.Sales.FIXTURES = [
{id: idx++, …Run Code Online (Sandbox Code Playgroud) 我最近将PC更新到Windows 8.1,以使其与Kinect v2兼容.这是华硕N53S,具有以下规格:
运行Kinect v2配置验证程序时,除了USB控制器(甚至检测到Kinect)外,我将所有项目都设置为绿色.我想这意味着USB集线器不兼容或缺少驱动程序.
我看了一下设备管理器,看到wdf kinectsensor接口0旁边有一个黄色警告.警告包含代码10,表示无法启动设备.
否则,所有驱动程序都是最新的.
我一直在浏览很多,发现其他拥有相同USB控制器的人也有类似的问题,但没有提及解决方案.
有没有人知道问题可能是什么?
简而言之:
有没有一种方法可以将多个可滚动的小部件(例如SingleSchildScrollView)同步在一起?
我只想要2个可滚动项,可以在我滚动一个时滚动另一个。
这样,我可以Stack将它们放在彼此的顶部,而后面的一个可以跟随前面的一个滚动。
或将它们放在另一组中Column,Row以便它们是分开的,但仍可以通过滚动其中一个来滚动。
我尝试使用,controller但似乎并没有按照我的想法做。
尝试下面的代码,例如,“ RIGHT”将在“ LEFT”的前面,如果我尝试滚动它们,则只有RIGHT会移动。那么如何同时将它们一起移动?
请不要告诉我将堆栈放在a内ListView,那不是我所需要的。
class _MyHomePageState extends State<MyHomePage> {
final ScrollController _mycontroller = new ScrollController();
@override
Widget build(BuildContext context) {
body:
Container(
height: 100,
child:
Stack( children: <Widget>[
SingleChildScrollView(
controller: _mycontroller,
child: Column( children: <Widget>[
Text('LEFT '),
Text('LEFT '),
Text('LEFT '),
Text('LEFT '),
Text('LEFT '),
Text('LEFT '),
],)
),
SingleChildScrollView(
controller: _mycontroller,
child: Column(children: <Widget>[
Text(' RIGHT'),
Text(' RIGHT'),
Text(' RIGHT'),
Text(' …Run Code Online (Sandbox Code Playgroud) controller ×10
angularjs ×2
testing ×2
dart ×1
domain-model ×1
driver ×1
ember.js ×1
flutter ×1
fresco ×1
grails ×1
ios5 ×1
javascript ×1
karma-runner ×1
kinect ×1
model ×1
nosql ×1
refresh ×1
routes ×1
ruby ×1
scroll ×1
session ×1
storyboard ×1
tabs ×1
usb ×1
user-data ×1