1
我有一個UIView子類,我重寫了多點觸摸處理方法。我的問題是,如果我使用該視圖上的給定觸摸進行計算,那麼它會打破模型視圖控制器設計模式?。計算後,我必須隱藏視圖,打印結果並更新我的核心數據模型。我對此感到困惑。在UIView子類中執行計算打破了MVC的設計模式?
編輯:
一些代碼。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// getting all the touches in the given gesture sequence
NSSet *allTouches = [event allTouches];
// checking taps count
if ([allTouches count] == 3)
{
// here I print the results and do the calculations
[self validateGestureSequenceWithTouches:allTouches];
}
// cleaning the view
NSArray *subviews = [self subviews];
for (UIView *view in subviews) {
if (![view isKindOfClass:[UINavigationBar class]])
[view removeFromSuperview];
}
}
你的意思是「保持它在視圖或控制器」,我假設。 – rdelmar
發送回調方法和視圖結果以便控制器可以管理結果是一種很好的做法?我的意思是,我會從UIViewController中獲得它,但是從UIView子類中完成它是好事嗎? – thxou
@ThXou這取決於你試圖實現的一種邏輯:如果計算可以在視圖之間共享,或者當視圖不是特定的時候,把它放到控制器中是一個好主意。另一方面,當計算視圖特定時,保持視圖更好。 – dasblinkenlight