In this paper, we study the problem of minimizing the weighted sum of the delay and energy consumption for task computation and transmission in an unmanned aerial vehicle (UAV)-assisted cellular network, where the UAV collaborates with base stations (BSs) under the control of software defined network (SDN) controller. In particular, the UAV acts as a computing server to compute users' tasks or as a relay node to forward tasks to BSs equipped with mobile edge computing (MEC) capacities. With the assistance of the UAV, users' tasks can be computed in three modes, including local computing mode, UAV computing mode, and edge computing mode. SDN controller dynamically adjusts the task computing mode and resource allocation scheme to meet the users' needs. The proposed problem is formulated as an optimization problem whose goal is to minimize the weighted sum of the delay and energy consumption of the UAV and all users by adjusting the task computing mode and resource allocation scheme. The proposed problem is a mixed-integer combined non-convex problem and it is hard to solve. We propose a joint mode selection and resource allocation optimization algorithm to solve it, where the original problem is decoupled into two subproblems, i.e., task computing mode selection subproblem and resource allocation subproblem. These two subproblems are solved alternatively by the branch and bound (BB) method and the convex optimization method, respectively. Simulation results show that the proposed algorithm can reduce the weighted sum of the delay and energy consumption of the UAV and all users by up to 33.2% and 55.7% compared to cases that computed with random mode selection and fully computed locally, respectively.