我创建了一个MVC项目,我想从过滤器中将模型设置为View.
但我不知道,我怎么能这样做.
该模型:
public class TestModel
{
public int ID { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Contorller:
[CustomFilter(View = "../Test/Test")]//<===/Test/Test.cshtml
public ActionResult Test(TestModel testModel)//<===Model from Page
{
//the Model has Value!!
// if has some exception here
return View(model);//<=====/Test/Test.cshtml
}
Run Code Online (Sandbox Code Playgroud)
过滤器(只是演示):
public override void OnActionExecuting(ActionExecutingContext filterContext){
ViewResult vr = new System.Web.Mvc.ViewResult()
{
ViewName = this.View,//<======/Test/Test.cshtml
ViewData = filterContext.Controller.ViewData
};
//How can I set Model here?!!
vr.Model = ???? //<========the Model is only get
filterContext.Result …
Run Code Online (Sandbox Code Playgroud) 如果我绘制我的图像我修复了问题使用CGAffintrasform
CGAffineTransform myTr = CGAffineTransformMake(1, 0, 0, -1, 0, backImage.size.height);
CGContextConcatCTM(context, myTr);
[backImage drawInRect:CGRectMake(cbx, -cby, backImage.size.width, backImage.size.height)];
myTr = CGAffineTransformMake(1, 0, 0, -1, 0, backImage.size.height);
CGContextConcatCTM(context, myTr);
Run Code Online (Sandbox Code Playgroud)
当我想写文件我用这个
NSData *imageData = UIImageJPEGRepresentation(backImage, 0);
Run Code Online (Sandbox Code Playgroud)
然后图像颠倒了怎么样?
我做一个类扩展LinearLayout我想显示一个像这样的Rect:
--------------------- => it is round corner
| border frame | .
| ----------------- | .
| | hearder | | .
| | - - - - - - - | | .
| | center | | .
| | | | .
| | - - - - - - - | | .
| | buttom | | .
| ---------------- | .
| | .
---------------------- .
. . . . . . . . …
Run Code Online (Sandbox Code Playgroud) 我做一个自定义UITableViewCell:
SListViewCell * cell = nil;
// cell = [listView dequeueReusableCellWithIdentifier:CELL];
if (!cell) {
cell = [[[SListViewCell alloc] initWithReuseIdentifier:CELL] autorelease];
}
listView.separatorColor = [UIColor clearColor];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.tag = index;
[btn setFrame:CGRectMake(0, 0, 42, 42)];
//setBtnImage will download image from network. when the UIButton click it is will change button image
[self setBtnImage:index btn:btn];
[btn addTarget:self action:@selector(typeTapped:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:btn];
return cell;
Run Code Online (Sandbox Code Playgroud)
typeTapped方法:
-(void)typeTapped:(id)sender
{
UIButton* btn = (UIButton)sender;
//download …
Run Code Online (Sandbox Code Playgroud) 错误不是每次都有.我曾尝试清理和重建应用程序,但它也是.
错误:
*** Assertion failure in -[UIWindowController
transition:fromViewController:toViewController:target:didEndSelector:],
/SourceCache/UIKit_Sim/UIKit-2372/UIWindowController.m:211
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Attempting to begin a modal transition from
<UINavigationController: 0x9190730> to <UINavigationController: 0x83a9dc0>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'
*** First throw call stack:
(0x213d012 0x1e85e7e 0x213ce78 0x191bf35 0x10b8d05 0xeb74f3 0xeb7777 0x10be033f
0xeb77b7 0x104f0 0x1e996b0 0x18c6035 0x20c0f3f 0x20c096f 0x20e3734 0x20e2f44
0x20e2e1b 0x36437e3 0x3643668 0xdcd65c 0x1133f2 0x25c5)
libc++abi.dylib: terminate called throwing an exception …
Run Code Online (Sandbox Code Playgroud) 我有三个控制器,我想知道控制器是推或弹
控制器:
{
if(!b)
b = [B alloc] init];
[self.navigationController pushViewController:b animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
B控制器:
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//I want here to judge, from the "A" push over, or to return from the "C" "pop"
//if it is push from A
//dosomething.....
//if it is pop from C
//dosomething
}
-(void)testAction:(id)sender
{
C *c = [[C alloc] init];
[self.navigationController pushViewController:b animated:YES];
[c release];
}
Run Code Online (Sandbox Code Playgroud)
C控制器:
{
[self.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我的sql是:
select (select count(*) from TblRMember where sex=1) male,
(select count(*) from TblRMember where sex=2) female,
(select count(*) from TblRMember where sex=0) unkown
Run Code Online (Sandbox Code Playgroud)
我希望Dapper.Net像这样返回一个Dictinary:
Keys:male,female,nukown
Value:10,30,50
Run Code Online (Sandbox Code Playgroud)
我看到如何使用Dapper Dot Net从数据库结果映射到Dictionary对象?,但那不行!
如何使用ToDictionary或其他方式实现我想要的
var myDictionary = sqlConnection.Query(strSql).ToDictionary(??);
Run Code Online (Sandbox Code Playgroud)
谢谢!